zoj4106 Lucky 7 in the Pocket

模拟过程
Name Result Time(ms) Memory(KB)
0 Accepted 5 440

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int main() {
int N;
int m,n;
cin>>N;
while (N--){
cin>>n;
if (n<=7){
m=7;
}else if(n%7==0&&n%4!=0){
m = n;
}else{
m = (n/7)*7+7;
if (m%4==0){
m = m+7;
}
}
cout<<m<<endl;
}
return 0;
}

发现规律
Name Result Time(ms) Memory(KB)
0 Accepted 5 312

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
using namespace std;
int main() {
int N;
int m,n;
cin>>N;
while (N--){
cin>>n;
for (int i = n; i <= 105; ++i) {
if (i%7==0 && i%4!=0){
cout<<i<<endl;
break;
}
}
}
return 0;
}

zoj4106 Lucky 7 in the Pocket
https://pisces34.github.io/2021/06/19/zoj/zoj4106/
发布于
2021年6月19日
许可协议