codeforces 333A

题意:保证不能正好配齐n,要求输出可以用的最大硬币数。

注意如果用到某种硬币,那么这种硬币就有无穷多个。所以11=3+3+3+3,12=9+9,13=3+3+3+3+3

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<cstdlib>
 4 #include<cmath>
 5 #include<algorithm>
 6 using namespace std;
 7 
 8 #define LL __int64
 9 
10 int main()
11 {
12     LL n,tot=3;
13     scanf("%I64d",&n);
14     while(1)
15     {
16         if(n%tot){
17             printf("%I64d
",n/tot+1);
18             break;
19         }
20         tot*=3;
21 
22     }
23     return 0;
24 }
View Code
原文地址:https://www.cnblogs.com/zstu-abc/p/3220193.html