您的位置:首页 > 其它

codeforces 333A - Secrets

2013-07-27 20:56 351 查看
题意:保证不能正好配齐n,要求输出可以用的最大硬币数。

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

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;

#define LL __int64

int main()
{
LL n,tot=3;
scanf("%I64d",&n);
while(1)
{
if(n%tot){
printf("%I64d\n",n/tot+1);
break;
}
tot*=3;

}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: