NOIP2017前恢复性训练
2017-09-11 18:32
330 查看
Emmmm....反正是又要从零开始了....
Day1 会写代码恢复性训练
小玉家的电费
不高兴的津津
津津的储蓄计划
铺地毯
级数求和
POJ 2386 也是好久没写八连块了...
三连击 这题居然还想了一会儿能不能用数论...
洛谷的题解中有一个判断两个集合相加相乘的 那个结论显然是错的 本题能过只是因为三位数找不到反例
这里贴一下自己的程序
Day1 会写代码恢复性训练
小玉家的电费
不高兴的津津
津津的储蓄计划
铺地毯
级数求和
POJ 2386 也是好久没写八连块了...
#include <cstdio> #include <cstring> #include <iostream> using namespace std; const int MAXM = 100 + 10; const int MAXN = 100 + 10; const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {0, 1, 0, -1}; char map[MAXN][MAXM]; int N, M; void dfs(int x, int y) { map[x][y] = '.'; for(int i = 1; i <= 3; ++i) for(int j = 1; j <= 3; ++j) { int nx = dx[i] + x, ny = dy[j] + y; if(nx >= 1 && nx <= N && ny >= 0 && ny < M && map[nx][ny] == 'W') dfs(nx, ny); } return; } int main() { while( ~scanf("%d%d", &N, &M)) { int ans = 0; for(int i = 1; i <= N; ++i) scanf("%s", map[i]); for(int i = 1; i <= N; ++i) for(int j = 0; j < M; ++j) { if(map[i][j] == 'W') { dfs(i, j); ans++; } } printf("%d\n", ans); } return 0; }
三连击 这题居然还想了一会儿能不能用数论...
洛谷的题解中有一个判断两个集合相加相乘的 那个结论显然是错的 本题能过只是因为三位数找不到反例
这里贴一下自己的程序
#include <cstdio> #include <iostream> #include <cstring> using namespace std; bool vis[20]; inline bool check(int x) { int a = x / 100, b = (x % 100 - x % 10) / 10, c = x % 10; if(a == b || a == c || b == c || b == 0 || c == 0) return false; if(vis[a] == false && vis[b] == false && vis[c] == false) { vis[a] = true; vis[b] = true; vis[c] = true; return true; } else return false; } int main() { for(int a = 123; a <= 333; ++a) { memset(vis, false, sizeof(vis)); int b = a * 2, c = a * 3; int x = a / 100, y = (a % 100 - a % 10) / 10, z = a % 10; if(x == y || x == z || y == z || y == 0 || z == 0) continue; vis[x] = true; vis[y] = true; vis[z] = true; if(check(b) && check(c)) printf("%d %d %d\n", a, b, c); } return 0; }
相关文章推荐
- JZOJ 5460. 【NOIP2017提高A组冲刺11.7】士兵训练
- JZOJ5460. 【NOIP2017提高A组冲刺11.7】士兵训练
- NOIP2017训练日记
- NOIP2017普及组比赛总结
- (2017多校训练第四场)HDU - 6078 Wavel Sequence dp
- JZOJ5390. 【NOIP2017提高A组模拟9.26】逗气
- [NOIP2017普及组]成绩
- JZOJ 5475. 【NOIP2017提高组正式赛】逛公园
- 纪中训练 day4 【NOIP普及组】模拟赛D组 解题报告
- 2017NOIp 普及组第三题 棋盘
- NOIP2017提高组D2T2[宝藏]
- JZOJ 5393. 【NOIP2017提高A组模拟10.5】Snake vs Block
- JZOJ 5395. 【NOIP2017提高A组模拟10.6】Count
- 【jzoj5286】【NOIP2017提高A组模拟8.16】【花花的森林 】【时间倒流】
- 2017多校训练Contest2: 1003 Maximum Sequence hdu6047
- NOIP 2017 提高组 K: 奶酪 (SPFA || 并查集)
- 【(好题)组合数+Lucas定理+公式递推(lowbit+滚动数组)+打表找规律】2017多校训练七 HDU 6129 Just do it
- [NOIP2017模拟]Date
- 「2017 Multi-University Training Contest 8」2017多校训练8
- 2017暑假训练第十七天