QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693536 | #9531. Weird Ceiling | yuanwuyuwu | Compile Error | / | / | C++14 | 1.5kb | 2024-10-31 16:20:41 | 2024-10-31 16:20:44 |
Judging History
answer
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
const int maxn=1e5+10;
ll f(ll a,ll b){
ll i=b;
while(i>=2){
if(a%i==0){
return a/i;
}
i--;
}
return a;
}
ll sum(ll n){
ll ans=0;
for(ll i=1;i<=n;i++){
ans+=f(n,i);
}
return ans;
}
ll cal_1(ll n){
ll current=n;
ll ans=n+1;
ll sqrt_n=sqrt((double)n);
cout<<"test"<<endl;
cout<<sqrt_n<<endl;
ll count=0;
for(int i=2;i<=sqrt_n;i++){
if(n%i==0){
ans+=count*current;
current=n/i;
}
else{
count++;
}
ans+=current;
}
cout<<ans<<endl;
ans+=(n-sqrt_n-1)*current;
return ans;
}
ll cal(ll n){
vector<ll> point;
ll sqrt_n=sqrt((double)n);
for(int i=1;i<=sqrt_n;i++){
if(n%i==0){
point.push_back(i);
point.push_back(n/i);
}
}
sort(point.begin(),point.end());
ll current=n;
ll ans=1;
for(int i=1;i<point.size();i++){
ans+=(point[i]-point[i-1])*(n/point[i-1]);
// cout<<"test="<<point[i]<<" "<<point[i-1]<<" "<<ans<<endl;
}
return ans;
}
int main(){
int T;
scanf("%d",&T);
while (T--){
ll n;
scanf("%lld",&n);
printf("%lld\n",cal(n));
// printf("check %lld %lld\n",cal(n),sum(n));
}
return 0;
}
Details
answer.code: In function ‘ll cal_1(ll)’: answer.code:29:15: error: ‘sqrt’ was not declared in this scope; did you mean ‘sqrt_n’? 29 | ll sqrt_n=sqrt((double)n); | ^~~~ | sqrt_n answer.code: In function ‘ll cal(ll)’: answer.code:49:15: error: ‘sqrt’ was not declared in this scope; did you mean ‘sqrt_n’? 49 | ll sqrt_n=sqrt((double)n); | ^~~~ | sqrt_n answer.code: In function ‘int main()’: answer.code:67:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | scanf("%d",&T); | ~~~~~^~~~~~~~~ answer.code:70:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 70 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~