QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#534089 | #9158. 分数 | yanshanjiahong | 10 | 5111ms | 3892kb | C++20 | 1.4kb | 2024-08-26 20:31:46 | 2024-08-26 20:31:46 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define ls(x) (x<<1)
#define rs(x) ((x<<1)|1)
#define mp make_pair
#define sec second
#define fir first
#define pii pair<int,int>
#define lowbit(i) i&-i
#define int long long
using namespace std;
typedef long long ll;
const int N=5e5+5,M=6,S=(1<<15)+5,inf=1e9+7,mo=998244353;
const double eps=1e-8;
void read(int &p){
int x=0,w=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-')w=-1;
ch=getchar();
}
while(isdigit(ch)){
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
p=x*w;
}
int n,m,upp;
int ans=0;
void getans(int a,int b,int c,int d,int lowv){
int maxv=min(a?(n-b)/a:inf,c?(m-d)/c:inf);
if(lowv&1)lowv++;
if(maxv&1)maxv--;
if(lowv<=maxv)ans+=((maxv-lowv)>>1)+1;
}
void dfs2(int a,int b,int c,int d,int lowv){
getans(a,b,c,d,lowv),getans(c,d,a,b,lowv);
for(int x=2;;x+=2){
int na=a*x+c,nb=b*x+d,nc=a,nd=b,nlv=max(lowv,x);
if(na*nlv+nb>min(n,m)||nc*nlv+nd>upp)break;
dfs2(na,nb,nc,nd,nlv);
}
}
void dfs1(int a,int b,int lowv){
for(int x=2;;x+=2){
int na=b,nb=b*x+a,nlv=max(lowv,x+1);
if(nb>upp||(nb*lowv+na)>upp)break;
dfs1(na,nb,nlv);
}
dfs2(b,a,0,b,lowv);
}
signed main(){
read(n),read(m),upp=max(n,m);
dfs1(0,1,1);
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Pretest #1:
score: 5
Accepted
time: 0ms
memory: 3892kb
input:
99 99
output:
406
result:
ok 1 number(s): "406"
Pretest #2:
score: 5
Accepted
time: 0ms
memory: 3760kb
input:
98 97
output:
405
result:
ok 1 number(s): "405"
Pretest #3:
score: 0
Wrong Answer
time: 0ms
memory: 3892kb
input:
99 96
output:
395
result:
wrong answer 1st numbers differ - expected: '396', found: '395'
Pretest #4:
score: 0
Wrong Answer
time: 0ms
memory: 3824kb
input:
995 977
output:
11148
result:
wrong answer 1st numbers differ - expected: '11153', found: '11148'
Pretest #5:
score: 5
Accepted
time: 0ms
memory: 3824kb
input:
991 990
output:
11220
result:
ok 1 number(s): "11220"
Pretest #6:
score: 5
Accepted
time: 0ms
memory: 3748kb
input:
976 968
output:
10900
result:
ok 1 number(s): "10900"
Pretest #7:
score: 0
Wrong Answer
time: 1ms
memory: 3820kb
input:
7602 7864
output:
215546
result:
wrong answer 1st numbers differ - expected: '215706', found: '215546'
Pretest #8:
score: 0
Wrong Answer
time: 1ms
memory: 3764kb
input:
7959 7735
output:
220104
result:
wrong answer 1st numbers differ - expected: '220256', found: '220104'
Pretest #9:
score: 0
Wrong Answer
time: 1ms
memory: 3840kb
input:
7878 7863
output:
221152
result:
wrong answer 1st numbers differ - expected: '221162', found: '221152'
Pretest #10:
score: 0
Wrong Answer
time: 0ms
memory: 3760kb
input:
7788 7658
output:
215242
result:
wrong answer 1st numbers differ - expected: '215323', found: '215242'
Pretest #11:
score: 0
Wrong Answer
time: 4ms
memory: 3760kb
input:
95399 99767
output:
8278996
result:
wrong answer 1st numbers differ - expected: '8285295', found: '8278996'
Pretest #12:
score: 0
Wrong Answer
time: 4ms
memory: 3844kb
input:
98051 99642
output:
8437489
result:
wrong answer 1st numbers differ - expected: '8439713', found: '8437489'
Pretest #13:
score: 0
Wrong Answer
time: 2ms
memory: 3772kb
input:
95624 96007
output:
8067652
result:
wrong answer 1st numbers differ - expected: '8068127', found: '8067652'
Pretest #14:
score: 0
Wrong Answer
time: 4ms
memory: 3840kb
input:
99208 98047
output:
8411003
result:
wrong answer 1st numbers differ - expected: '8412610', found: '8411003'
Pretest #15:
score: 0
Wrong Answer
time: 61ms
memory: 3784kb
input:
997417 967722
output:
229830958
result:
wrong answer 1st numbers differ - expected: '229917323', found: '229830958'
Pretest #16:
score: 0
Wrong Answer
time: 60ms
memory: 3848kb
input:
987807 956529
output:
226336553
result:
wrong answer 1st numbers differ - expected: '226426912', found: '226336553'
Pretest #17:
score: 0
Wrong Answer
time: 57ms
memory: 3804kb
input:
971654 984345
output:
228329038
result:
wrong answer 1st numbers differ - expected: '228363805', found: '228329038'
Pretest #18:
score: 0
Wrong Answer
time: 908ms
memory: 3848kb
input:
7892259 7983727
output:
4646987632
result:
wrong answer 1st numbers differ - expected: '4647501224', found: '4646987632'
Pretest #19:
score: 0
Wrong Answer
time: 1665ms
memory: 3848kb
input:
7937869 29796968
output:
12650511464
result:
wrong answer 1st numbers differ - expected: '15197555613', found: '12650511464'
Pretest #20:
score: 0
Wrong Answer
time: 5111ms
memory: 3808kb
input:
29717543 29510173
output:
30902392333
result:
wrong answer 1st numbers differ - expected: '30904211576', found: '30902392333'
Final Tests
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
96 98
output:
395
result:
wrong answer 1st numbers differ - expected: '396', found: '395'
Test #2:
score: 5
Accepted
time: 0ms
memory: 3816kb
input:
100 99
output:
408
result:
ok 1 number(s): "408"
Test #3:
score: 5
Accepted
time: 0ms
memory: 3816kb
input:
99 99
output:
406
result:
ok 1 number(s): "406"
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 3808kb
input:
963 951
output:
10625
result:
wrong answer 1st numbers differ - expected: '10634', found: '10625'
Test #5:
score: 0
Wrong Answer
time: 0ms
memory: 3784kb
input:
958 974
output:
10786
result:
wrong answer 1st numbers differ - expected: '10795', found: '10786'
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
input:
966 990
output:
11000
result:
wrong answer 1st numbers differ - expected: '11003', found: '11000'
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 3768kb
input:
7958 7947
output:
224475
result:
wrong answer 1st numbers differ - expected: '224482', found: '224475'
Test #8:
score: 0
Wrong Answer
time: 0ms
memory: 3768kb
input:
7623 7730
output:
213387
result:
wrong answer 1st numbers differ - expected: '213444', found: '213387'
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 3848kb
input:
7845 7783
output:
218877
result:
wrong answer 1st numbers differ - expected: '218916', found: '218877'
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 3836kb
input:
7881 7773
output:
219367
result:
wrong answer 1st numbers differ - expected: '219451', found: '219367'
Test #11:
score: 0
Wrong Answer
time: 4ms
memory: 3808kb
input:
99414 98698
output:
8464177
result:
wrong answer 1st numbers differ - expected: '8465217', found: '8464177'
Test #12:
score: 0
Wrong Answer
time: 4ms
memory: 3892kb
input:
98249 96148
output:
8234661
result:
wrong answer 1st numbers differ - expected: '8237486', found: '8234661'
Test #13:
score: 0
Wrong Answer
time: 4ms
memory: 3844kb
input:
99003 96832
output:
8321872
result:
wrong answer 1st numbers differ - expected: '8324931', found: '8321872'
Test #14:
score: 0
Wrong Answer
time: 4ms
memory: 3884kb
input:
98266 96030
output:
8228012
result:
wrong answer 1st numbers differ - expected: '8231065', found: '8228012'
Test #15:
score: 0
Wrong Answer
time: 60ms
memory: 3852kb
input:
968207 958885
output:
223498013
result:
wrong answer 1st numbers differ - expected: '223522215', found: '223498013'
Test #16:
score: 0
Wrong Answer
time: 60ms
memory: 3844kb
input:
959846 998397
output:
228653831
result:
wrong answer 1st numbers differ - expected: '228770873', found: '228653831'
Test #17:
score: 0
Wrong Answer
time: 60ms
memory: 3852kb
input:
965821 972280
output:
225342305
result:
wrong answer 1st numbers differ - expected: '225359210', found: '225342305'
Test #18:
score: 0
Wrong Answer
time: 908ms
memory: 3812kb
input:
7855098 7962479
output:
4622340641
result:
wrong answer 1st numbers differ - expected: '4622947400', found: '4622340641'
Test #19:
score: 0
Wrong Answer
time: 1632ms
memory: 3844kb
input:
7841076 29648718
output:
12499144136
result:
wrong answer 1st numbers differ - expected: '15040798710', found: '12499144136'
Test #20:
score: 0
Wrong Answer
time: 5030ms
memory: 3848kb
input:
29365129 29012208
output:
30264702900
result:
wrong answer 1st numbers differ - expected: '30267839959', found: '30264702900'