【比赛】蔚来杯4
K题
wa点:中间乘法运算数位过大,爆int了
#include<bits/stdc++.h> using namespace std; #define ll long long //中间乘法爆int,导致正确率81% int n,A,B,x; int mxn; ll up[10]={1,10,100,1000,10000,100000,1000000,10000000}; int find(ll res,int goal) { for(int i=0;i<mxn;i++) { ll dis=(goal-res*up[i])%n; if(dis<0 ) dis+=n; if(dis < up[i] ) return i; } return mxn; } int main() { cin>>n; int cnt=0; mxn=7; if(n==1) cnt==0; else for(int i=1;i<=n;i++) { cnt+=find(i-1,i); } printf("%d",cnt); return 0; }