网址
https://codeforces.com/contest/2145/my
大家可以直接登录(先需要注册),做这道题。


题意:Monocarp想给三个侄儿分糖果,手里有n个,请问还需要买几个?这样才能使得每个侄儿得到的糖果一样多。换做数学公式就是,糖果的总数量 可以整除3,或者说除以3没有余数。
就是(手里的+要买的)整除3,需要知道要买的数量最小值是多少?
非常简单,可惜昨晚没来及参加这个比赛。
#include <iostream>
using namespace std;
void solve2145A()
{
int nephews = 3;
bool is_finding = true;
int need_buy_candy = 0;
int n = 0;
cin >> n;
while (is_finding == true)
{
if ((n + need_buy_candy) % nephews == 0)
{
is_finding = false;
}
else
{
need_buy_candy++;
}
}
cout << need_buy_candy << endl;
}
int main()
{
int t = 0;
cin >> t;
while (t--)
{
solve2145A();
}
return 0;
}
有时候可能比赛没有想象那么难,参与也很重要!
今天做了三道题,虽然另外两道不是全对。
1261

被折叠的 条评论
为什么被折叠?



