10 条题解
-
0
# 菜题 #include <bits/stdc++.h> using namespace std; int main() { int a[6]; int b[6]; int c[6]; a[0]=1; a[1]=1; a[2]=2; a[3]=2; a[4]=2; a[5]=8; for (int i=0; i<6; i++) { cin >>b[i]; } for (int i=0; i<6; i++) { if (b[i]<a[i]) { c[i]=a[i]-b[i]; } else { c[i]=a[i]-b[i]; } } for (int i=0; i<6; i++) { cout <<c[i]<<" "; } return 0; }
-
0
#include <bits/stdc++.h>//by hetao4185102 using namespace std; int a, b, c, d, e, f; int main() { cin >> a >> b >> c >> d >> e >> f; if(a != 1) cout << 1 - a << " "; else cout << 0 << " "; if(b != 1) cout << 1 - b << " "; else cout << 0 << " "; if(c != 2) cout << 2 - c << " "; else cout << 0 << " "; if(d != 2) cout << 2 - d << " "; else cout << 0 << " "; if(e != 2) cout << 2 - e << " "; else cout << 0 << " "; if(f != 8) cout << 8 - f << " "; else cout << 0 << " "; return 0; }
-
0
#include <bits/stdc++.h>//by hetao4185102 using namespace std; int a, b, c, d, e, f; int main() { cin >> a >> b >> c >> d >> e >> f; if(a != 1) cout << 1 - a << " "; else cout << 0 << " "; if(b != 1) cout << 1 - b << " "; else cout << 0 << " "; if(c != 2) cout << 2 - c << " "; else cout << 0 << " "; if(d != 2) cout << 2 - d << " "; else cout << 0 << " "; if(e != 2) cout << 2 - e << " "; else cout << 0 << " "; if(f != 8) cout << 8 - f << " "; else cout << 0 << " "; return 0; }
-
-2
这题很简单,暴力计算就好
#include <bits/stdc++.h>//by hetao4185102 using namespace std; int a, b, c, d, e, f; int main() { cin >> a >> b >> c >> d >> e >> f; if(a != 1) cout << 1 - a << " "; else cout << 0 << " "; if(b != 1) cout << 1 - b << " "; else cout << 0 << " "; if(c != 2) cout << 2 - c << " "; else cout << 0 << " "; if(d != 2) cout << 2 - d << " "; else cout << 0 << " "; if(e != 2) cout << 2 - e << " "; else cout << 0 << " "; if(f != 8) cout << 8 - f << " "; else cout << 0 << " "; return 0; }
-
-13
这个问题的解决思路是先计算出每种棋子需要添加或删除的数量,然后将结果输出。
对于国王和皇后,由于每套正确的棋子只能有一个,所以如果输入的数量大于1,则需要删除多余的棋子,即数量减去1。如果数量为0,则需要添加一个棋子,即1减去数量。
对于车、象和马,由于每套正确的棋子都需要两个,所以如果输入的数量大于2,则需要删除多余的棋子,即数量减去2。如果数量小于2,则需要添加缺少的棋子,即2减去数量。
对于兵,由于每套正确的棋子需要8个,所以如果输入的数量大于8,则需要删除多余的棋子,即数量减去8。如果数量小于8,则需要添加缺少的棋子,即8减去数量。
以上就是求解这个问题的思路,根据输入的棋子数量和上述规则,计算出每种棋子需要添加或删除的数量,并将结果输出。
#include <iostream> int main() { int king, queen, rook, bishop, knight, pawn; std::cin >> king >> queen >> rook >> bishop >> knight >> pawn; int missingKing = 1 - king; int missingQueen = 1 - queen; int missingRook = 2 - rook; int missingBishop = 2 - bishop; int missingKnight = 2 - knight; int missingPawn = 8 - pawn; std::cout << missingKing << " " << missingQueen << " " << missingRook << " " << missingBishop << " " << missingKnight << " " << missingPawn << std::endl; return 0; }
- 1
信息
- ID
- 355
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 1
- 标签
- (无)
- 递交数
- 386
- 已通过
- 293
- 上传者