丙组T1:https://www.iai.sh.cn/problem/17
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
n %= 5;
if(n >= 1 && n <= 3) cout << "Fishing";
else cout << "Lying";
return 0;
}
丙组T2:https://www.iai.sh.cn/problem/14
#include <bits/stdc++.h>
using namespace std;
//加密规则就是将4位数翻转,然后每个数x变成9-x
//解密就是翻转,然后同样每个数x变成9-x
int main()
{
string s;
cin >> s;
for(int i = s.size() - 1; i >= 0; i--)
{
cout << 9 - (s[i] - '0');
}
return 0;
}
丙组T3:https://www.iai.sh.cn/problem/11
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int a, b;
int flag[N]; //标记合数
//先用埃氏筛筛出1000000范围内所有的质数、合数
//再枚举a~b之间每个数x,判断x和x去掉个位数是否都是质数
//如果一个都没有,输出None
int main()
{
bool yes = false;
flag[0] = true; //0不是质数
flag[1] = true; //1不是质数
//埃氏筛
for(int i = 2; i <= N; i++)
{
if(!flag[i])
{
for(int j = i + i; j <= N; j += i)
{
flag[j] = true;
}
}
}
cin >> a >> b;
for(int i = a; i <= b; i++)
{
//枚举a~b,判断是否是双质数,必须是两位数以上,注意如果一位数flag[0]会被判断为是质数,除非把flag[0]初始化为true
if(!flag[i] && !flag[i / 10])
{
cout << i << endl;
yes = true;
}
}
if(!yes) cout << "None";
return 0;
}
丙组T4:https://www.iai.sh.cn/problem/13
#include <bits/stdc++.h>
using namespace std;
const int N = 100005, MOD = 10000;
int n;
int a[N];
int pre[N]; //前缀积
int sub[N]; //后缀积
int main()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
//初始化
pre[0] = sub[n + 1] = 1;
//计算前缀积
for(int i = 1; i <= n; i++) pre[i] = pre[i - 1] * a[i] % MOD;
//计算后缀积
for(int i = n; i >= 1; i--) sub[i] = sub[i + 1] * a[i] % MOD;
//Pi = a[1]*a[2]*...a[i-1] * a[i+1]*a[i+2]*...a[n]
//pre[i-1] = a[1]*a[2]*...a[i-1]
//sub[i+1] = a[i+1]*a[i+2]*...a[n]
for(int i = 1; i <= n; i++)
{
int p = pre[i - 1] * sub[i + 1] % MOD;
cout << p << endl;
}
return 0;
}
丙组T5:https://www.iai.sh.cn/problem/15
#include <bits/stdc++.h>
using namespace std;
struct node
{
int id; //编号
int start; //出发时间,转成分钟
int end; //达到时间,转成分钟
} a[1005];
bool cmp(node a, node b)
{
if(a.end != b.end) return a.end < b.end;
if(a.start != b.start) return a.start < b. start;
return a.id < b.id;
}
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i++)
{
string s, x;
cin >> s >> x;
int sh = (s[0] - '0') * 10 + s[1] - '0'; //开始时间的小时
int sm = (s[3] - '0') * 10 + s[4] - '0'; //开始时间的分钟
int xh = (x[0] - '0') * 10 + x[1] - '0'; //路程时间的小时
int xm = (x[3] - '0') * 10 + x[4] - '0'; //路程时间的分钟
//更简单的输入开始小时、开始分钟、路程小时、路程分钟的方法
//scanf("%d:%d %d:%d", &sh, &sm, &xh, &xm);
a[i].id = i;
a[i].start = sh * 60 + sm;
a[i].end = a[i].start + xh * 60 + xm;
}
sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= n; i++) cout << a[i].id << endl;
return 0;
}
标签:月赛,end,int,上海,start,sh,2020,using,main From: https://www.cnblogs.com/jcwy/p/18295000