[2016-04-17][Gym][100947][D][The Three Kings of Asgard]
时间:2016-04-17 16:45:30 星期日
题目编号:[2016-04-17][Gym][100947][D][The Three Kings of Asgard]
题目大意:A给B和当前一样多的金币,B给C,然后C又给A,结束之后,A,B,C三人的金币刚好一样多,问原来A,B,C各有多少个金币,不可能就输出 Impossible
分析:
- 直接解方程组
- 得到
遇到的问题:当不能整除4和8的时候,不可能
#include<cstdio>using namespace std;int main(){int t;scanf("%d",&t);while(t--){long long n;scanf("%I64d",&n);if(n % 8 || n % 4){puts("Impossible");}else {long long a = 11*n/8,b = 7 * n / 8,c = 3 * n / 4;printf("%I64d %I64d %I64d\n",a,b,c);}}}
浙公网安备 33010602011771号