bestlv


私信TA

用户名:peikailv

访问量:944

签 名:

等  级
排  名 2874
经  验 2037
参赛次数 0
文章发表 11
年  龄 0
在职情况 学生
学  校 福州大学
专  业 计算机类

  自我简介:


解题思路:

注意事项:

参考代码:

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int n,a[1001],ans[1001];
int cl(int n)
{
	int temp=0;
	int t=n/3,sheng=n%3;
	sheng+=t;
	temp=t;
	while(sheng>=3)
	{
	    int t1;
	    t1=sheng/3;
	    sheng=sheng%3+t1;
		temp+=t1;

	}

	if(sheng==2) temp+=1;
	
	return temp;
}
int main()
{
    while(cin>>n)
    {
		if(n==0) break;
		
		int nas=cl(n);
		cout<<nas<<endl;
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区