QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863600 | #3004. It's a Mod, Mod, Mod, Mod World | isWFnoya# | WA | 20ms | 3840kb | C++26 | 1.0kb | 2025-01-19 19:56:24 | 2025-01-19 19:56:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1919810;
typedef long long ll;
typedef pair<ll,ll> PII;
ll p,q,n;
int a[N],b[N];
char s[N],t[N];
ll dp[N][114];
ll gg,fjd,cnt,tot,base;
ll cal1(ll x){
ll cc=x/cnt;
ll mul=cnt*q;
ll res=(fjd+fjd+cc-1)*cc/2*mul;
x%=cnt;
ll ffjd=fjd+cc;
res+=ffjd*q*x;
// cout<<"--"<<res<<endl;
return res;
}
void __(){
scanf("%lld%lld%lld",&p,&q,&n);
p%=q;
if(p==0){
puts("0");
return;
}
gg=__gcd(p,q);
fjd=q%p;
cnt=q/p;
tot=q/gg;
base=(q-gg)*(tot)/2;
ll ans=base*(n/q);
// ans+=(1+n)*n/2*p;
n%=q;
ans+=(1+n)*n/2*p;
// n++;
// cout<<base<<endl;
if(n>fjd*(cnt+1)){
// ll val=n-fjd;
ans-=cal1(n-fjd*(cnt+1));
}
n=min(fjd,n);
cnt++;
fjd=0;
ans-=cal1(n);
printf("%lld\n",ans);
}
//0 3 6
//1 4 7
//2 5
//0 2 4 6
int main(){
int _=1;
cin>>_;
while(_--){
__();
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 20ms
memory: 3840kb
input:
91125 999956 999956 999956 999956 999956 999957 999956 999956 999958 999956 999956 999959 999956 999956 999960 999956 999956 999961 999956 999956 999962 999956 999956 999963 999956 999956 999964 999956 999956 999965 999956 999956 999966 999956 999956 999967 999956 999956 999968 999956 999956 999969 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1499868502881 499956500946 499957500902 499959500814 499961500725 499963500635 499965500544 499967500452 499969500359 499971500265 499973500170 499975500074 499977499977 499979499879 499981499780 499983499680 4...
result:
wrong answer 46th lines differ - expected: '499956500946', found: '1499868502881'