QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#47253 | #1175. Bags of Candies | Gemini7X | WA | 746ms | 13524kb | C++14 | 2.9kb | 2022-09-06 17:25:42 | 2022-09-06 17:25:44 |
Judging History
answer
/*
author : Gemini
date : September 6th, 2022
url : https://vjudge.net/contest/512482#problem/I
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=316305;
template<typename T>
void read(T &x){
T sgn=1;
char ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')sgn=-1;
for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0';
x*=sgn;
}
ll g[maxn<<1],a[maxn<<1];
int sq,tot,cnt;
void init(ll n){
cnt=tot=0;
sq=sqrt(n);
for(ll i=1;i<=n;i=a[tot]+1){
a[++tot]=n/(n/i);
g[tot]=a[tot]-1;
}
auto id=[n](ll x){
return x<=sq?x:tot-n/x+1;
};
for(int i=2;i<=sq;i++){
if(g[i]!=g[i-1]){
cnt++;
for(int j=tot;a[j]>=1ll*i*i;j--){
g[j]-=g[id(a[j]/i)]-cnt+1;
}
}
}
}
int main(){
init(100000000000ll);
int T;
read(T);
while(T--){
ll n;
read(n);
if(n==1){
puts("1");
}else if(n==2){
puts("2");
}else{
auto id=[n](ll x){
return x<=sq?x:tot-n/x+1;
};
ll num=g[id(n)]-g[id(n/2)]+1;
printf("%lld\n",(n-num+1)/2+num);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 741ms
memory: 13492kb
input:
2 4 9
output:
3 6
result:
ok 2 number(s): "3 6"
Test #2:
score: 0
Accepted
time: 739ms
memory: 13452kb
input:
5 2 3 4 5 6
output:
2 3 3 4 4
result:
ok 5 number(s): "2 3 3 4 4"
Test #3:
score: 0
Accepted
time: 736ms
memory: 13524kb
input:
5 1111 2018 3333 4006 5555
output:
599 1078 1772 2128 2942
result:
ok 5 number(s): "599 1078 1772 2128 2942"
Test #4:
score: -100
Wrong Answer
time: 746ms
memory: 13496kb
input:
5 26666666 10000000 23456789 27777777 24444442
output:
1012533452 1004200119 1010928513 1013089007 1011422340
result:
wrong answer 1st numbers differ - expected: '13730373', found: '1012533452'