メモ

yukicoderでゆるふわgolf

yukicoder No.532 Possible or Impossible

問題はこち
No.532 Possible or Impossible - yukicoder

M+0*(残り) の形が作れれば十分
●M≧4のとき
M+(3-2-1)*(残り)
●M=3のとき
・N=3のとき:3*(2-1)
・N=4のとき:4+2-1*3
・N≧5のとき:3+(5-4-1)*(残り)
●M=2のとき
・N=2のとき:2*1
・N=3のとき:3-2+1
・N≧4のとき:2+(4-3-1)*(残り)
●M=1のとき
・N=1のとき:1
・N=2のとき:2-1
・N=3のとき:3-2*1
・N=4のとき:1*2+3-4
・N≧5のとき:1+(5-3-2)*(残り)
●M=0のとき
・N≦2のとき:無理
・N≧3のとき:(3-2-1)*(残り)

ということで、不可能なのはM=0かつN≦2のときのみ

n,m;
main(){
	scanf("%d%d",&n,&m);
	if(m==0 && n<=2)put("Impossible");
	else puts("Possible");
}

ぎゅ
定数2のところにscanfの返り値が使える

main(n,m){puts(scanf("%d%d",&n,&m)<n|m?"Possible":"Impossible");}

65B