QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623167#7055. A Hard ProblemtravelTL 0ms3628kbC++14873b2024-10-09 10:28:112024-10-09 10:28:12

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 10:28:12]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3628kb
  • [2024-10-09 10:28:11]
  • 提交

answer

//
// Created by travel on 2024/10/9.
//
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> PII;
#define endl "\n"
#define ft first
#define sd second
#define pb push_back
const int mod = 1e9 + 7;
void solve(){
    int n; cin>>n;
    int last = 0;
    for(int i = 2;i <= n;i++){
        int cnt = 0;
        for(int j = 2;;j++){
            int x = i * j;
            if(x <= n) {
                cnt++;
                break;
            }
            else break;
        }
        if(cnt == 0){
            last = i;
            break;
        }
//        cout<<i<<endl;
    }
    int res = n - last + 2;
    cout<<res<<endl;
}
signed main() {
//    ios::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);
    int T ;
    cin>>T;
    while(T--)
        solve();

    return 0;
}



详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

4
2
3
4
5

output:

2
3
3
4

result:

ok 4 lines

Test #2:

score: -100
Time Limit Exceeded

input:

100000
6
18
54
162
486
1458
4374
13122
39366
118098
354294
1062882
3188646
9565938
28697814
86093442
258280326
774840978
324522916
973568748
920706226
762118660
286355962
859067886
577203640
731610911
194832715
584498145
753494426
260483260
781449780
344349322
33047957
99143871
297431613
892294839
6...

output:

4
10
28
82
244
730
2188
6562
19684
59050
177148
531442
1594324
4782970
14348908
43046722
129140164
387420490
162261459
486784375
460353114
381059331
143177982

result: