QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353642 | #8340. 3 Sum | ucup-team004# | WA | 0ms | 3832kb | C++20 | 975b | 2024-03-14 14:19:07 | 2024-03-14 14:19:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n,k,ans;
const int N=505;
const ll mod=(ll)(1e17)+7;
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
ll a[N];
ll get(string s){
reverse(s.begin(),s.end());
ll sum=0;
vector<int> a(k+1);
For(i,0,k-1)for(int j=i;j<s.length();j+=k){
a[i]+=s[j]-'0';
}
do{for(int i=0;i<k;i++){a[i+1]+=a[i]/10; a[i]%=10;} a[0]=a[k]; a[k]=0;}
while(a[0]>=10);
For(i,0,k-1)sum=(sum*10+a[i])%mod;
return sum;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
cin>>n>>k;
For(i,0,n-1){
string s;
cin>>s;
a[i]=get(s);
//cerr<<a[i]<<endl;
}
ll ald=0;
For(i,0,k-1)ald=(ald*10+9)%mod;
For(i,0,n-1)For(j,i,n-1)For(k,j,n-1){
ll t=(a[i]+a[j]+a[k])%mod;
if(t==ald||t==0||t==ald*2%mod||t==ald*3%mod)ans++;
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3832kb
input:
4 1 0 1 10 17
output:
20
result:
wrong answer 1st numbers differ - expected: '3', found: '20'