「CFgym100541」ATM withdrawal
题解
显然低位不涉及进位的问题。。。
所以预处理组成1-9的最少个数和方案
低于c的按位统计,其余乱搞一下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<set> #include<ctime> #include<vector> #include<queue> #include<algorithm> #include<map> #include<cmath> #define eps 1e-6 #define inf 1000000000 #define mod 1000000009 #define pa pair<int,int> #define ll long long using namespace std; ll read() { ll x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } ll T,n,c; int s[10]={0,1,1,1,2,1,2,2,2,3}; int t[10]={1,1,1,1,2,1,2,1,1,3}; void solve() { ll a1=0,a2=1; n/=1000; for(int i=1;i<=c;i++) { int tmp=n%10; a1+=s[tmp],a2*=t[tmp]; n/=10; } if(n<=5) a1+=s[n],a2*=t[n]; else { a1+=n/5-1; n=n%5+5; a1+=s[n],a2*=t[n]; } cout<<a1<<' '<<a2<<endl; } int main() { T=read(); while(T--) { n=read();c=read(); if(n%1000)puts("0"); else solve(); } return 0; } |
Subscribe