Time Exceeded
Code
//Fahmidur Rahman Nafi 62 [i]
#include <bits/stdc++.h>
using namespace std;
int max_div(int num) {
int highest = 1;
for (int i = num-1; i >= 1; i--) {
if (num % i == 0) {
highest = i;
break;
}
}
return highest;
}
int main(){
int t;
cin >> t;
while (t--){
int n;
cin >> n;
if (n % 2 == 0){
cout << n/2 << endl;
}
else{
int ans = max_div(n);
cout << ans << endl;
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1052 Yet Another Array Partition
- Contest
- Brain Booster #3
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 16:24:45
- Judged At
- 2024-11-11 03:33:09
- Judged By
- Score
- 25
- Total Time
- ≥1081ms
- Peak Memory
- ≥484.0 KiB