2819. 糖果

Li Dao

本人比较笨,就用最直接的方法吧

include

using namespace std;
int T,money;

void solve()
{
int suggar=0;
int paper=0;

suggar+=money;
paper+=suggar;
while(paper>=3)
{
int now_get=paper/3;
suggar+=now_get;
paper=paper%3+now_get;
}

cout<<suggar<>T;
for(int step=0;step>money;
solve();
}
return 0;
}

wxxyll

include

/ run this program using the console pauser or add your own getch, system(“pause”) or input loop /

int main(int argc, char** argv) {
int T;
int n;
scanf(“%d”,&T);
while(T–){
scanf(“%d”,&n);
int sum=n;
while(n>=3){
int temp=n/3;
sum+=temp;
int mod=n%3;
n=temp+mod;
}
printf(“%d\n”,sum);
}
return 0;
}

你当前正在回复 博客/题目
存在问题!