hrbust 1995 伟大的一食堂

来源:互联网 发布:php把soap 对象转json 编辑:程序博客网 时间:2024/05/17 06:25

SoL:根据题意,即可知道是对3取余和整除的运算找规律的题。

稍微推下就好。

#include <cstdio>#include <cstring>#include <string>#include <cmath>using namespace std;int N;int main(){while(~scanf("%d",&N)){int a,b,s;int cnt=0;while(1){a=N%3;b=N/3;s=a+b;cnt+=b;if(s==1) break;if(s==2){cnt++;break;}N=s;}printf("%d\n",cnt);}return 0;}


 

0 0
原创粉丝点击