3 条题解
-
2
用函数,不迷路!
已AC,请放心食用
#include <iostream> using namespace std; int six(int n) { int x = n; bool f = false; while (x > 0) { if (x % 10 == 6) { f = true; break; } x /= 10; } return f; } int main() { int n, num = 0; cin >> n; for (int i = 1; i <= n; i++) { if (six(i)) { num++; } } if (num % 2 == 1) { cout << "library"; } else { cout << "playground"; } return 0; }
养成好习惯,看后点个赞😎!
-
0
#include<bits/stdc++.h> using namespace std; int main() { int n, m, k = 0; cin >> n; for (int i = 1; i <= n; i++){ m = i; //短除法判断各个位是否有等于6 while(m > 0){ if(m%10 ==6){ k++;//计数器 break; } m /= 10; } } //判断含有6的数字的个数是奇数还是偶数 //是奇数,就去图书馆,否则就去游乐场 if(k % 2 == 0){ cout << "playground"; } else { cout << "library"; } return 0; }
- 1
信息
- ID
- 960
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- 递交数
- 78
- 已通过
- 41
- 上传者