#include <iostream> #include <queue> using namespace std; int main() { int cnt = 0; int x = 1200000; for (int i = 1; i <= x; i++ ) { if (x % i == 0) { cnt++; } } cout << cnt << endl; return 0; }
#include <iostream> #include <queue> using namespace std; int f(int x) { int cnt = 0; while (x) { if (x % 10 == 9) { cnt++; break; } x /= 10; } return cnt; } int main() { int cnt = 0; for (int i = 1; i <= 2019; i++) { cnt += f(i); } cout << cnt << endl; return 0; }
#include <iostream> #include <queue> using namespace std; bool f(int i) { int a = i % 10;//最後一位 i /= 10; if (i == 0) { return true; } while (i) { if (a < i % 10) return false; a = i % 10; i /= 10; } return true; } int main() { int cnt = 0; int n; cin >> n; for (int i = 1; i <= n; i++) { cnt += f(i); } cout << cnt << endl; return 0; }
#include <iostream> #include <queue> #include <vector> using namespace std; const int max = 105; char map[105][105]; int visit[105][105]; int n, m; int dir[4][2] = { {0, 1} , {1, 0} , {-1 , 0} , {0, -1} }; bool in(int x, int y) { if (x >= 0 && y >= 0 && x < n && y < m) return true; return false; } void change() { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (visit[i][j] == 2) { //能夠去擴增 for (int k = 0; k < 4; k++) { int dx = i + dir[k][0]; int dy = j + dir[k][1]; if (in(dx, dy) && visit[dx][dy] == 0) { map[dx][dy] = 'g'; visit[dx][dy] ++; } } } } } } void grow() { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (visit[i][j] != 0 ) visit[i][j] ++; } } } void print() { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { printf("%c", map[i][j], visit[i][j]); } printf("\n"); } } int main() { cin >> n >> m; int k; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> map[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (map[i][j] == 'g') { visit[i][j] ++; } } } cin >> k; grow(); while (k--) { change(); grow(); } print(); return 0; }