社区讨论
我的方法跑不出来,求大神解答!感恩
P1980[NOIP 2013 普及组] 计数问题参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @lvqhupq3
- 此快照首次捕获于
- 2024/05/03 17:50 2 年前
- 此快照最后确认于
- 2024/05/03 19:56 2 年前
按照这样的方法去求解,跑不出来,一直显示TLE,求大神解答哪里有问题?
CPP#include<iostream>
using namespace std ;
int main()
{
int n,x =0 ;
int fig = 1;//1-n的数字
int bit = 0;//割下来的个位数字
int time = 0 ;//出现次数
cin >> n ;
cin >> x ;
for(int i = 0 ; i < n ; i++)
{
int temfig = 0 ;
temfig=fig ;//把数字fig存入临时temfig,防止fig被改变
while(temfig>9)
{
bit = temfig % 10 ;
if (bit == x)
{
time++ ;
}
temfig = temfig/10 ;
}
while(temfig<10)
{
bit = temfig ;
if(bit == x )
{
time ++ ;
}
}
fig++ ;
}
cout << time ;
return 0 ;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...