【ACM】杭电OJ 1284(待更)

#include<iostream>
using namespace std;
int main(){
    int n;
	while(cin>>n){
		int ans=0;    
		for(int i=0;i<=n/3;i++){  
		    //对3的个数进行枚举 
			int temp=(n-3*i);     
			//除了这i个3之外剩余的钱数 
			//temp/2,剩余部分换成2的总种类数,
			ans+=temp/2+1;        
			//这个1,是指只有i个3,其余都是1的情况 
		}
		cout<<ans<<endl; 
	}	
	return 0;
} 

猜你喜欢

转载自blog.csdn.net/CSDN___CSDN/article/details/83817882