【第46题】[NOIP2013 普及组] 计数问题 2023-08-31 14:48:30 浏览数 (6) 题目:[NOIP2013 普及组] 计数问题题目原文请移步下面的链接https://www.luogu.com.cn/problem/P1980参考题解:https://www.luogu.com.cn/problem/solution/P1980标签:OI、模拟、字符串思路因为数据量很小,我们直接暴力模拟一下就行外层最多10^6,里层最多6次,百分百撑得住对每一位取余10,如果这一位是1那么就统计一次就行了AC代码代码语言:javascript复制#include <bits/stdc .h> using namespace std; #define endl 'n'; int main() { int n, a; cin >> n >> a; int ans = 0; int j; for (int i = 1; i <= n; i) { j = i; while (j != 0) { if (j % 10 == a) { ans ; } j /= 10; } } cout << ans; return 0; }END https com int 统计 字符串 0 人点赞 上一篇:分享雷军22年前编写的代码