题解 | #挑7#

杨辉三角的变形

http://www.nowcoder.com/practice/8ef655edf42d4e08b44be4d777edbf43

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int d;
    while(cin>>d)
    {
        int count=0;
        for(int i=7;i<=d;i++)
        {
            if(i%7==0||(i-7)%10==0)
            {
                count++;
            }
            else
            {
                string s=to_string(i);
                int index=s.find('7');
                if(index<s.size())
                {
                    count++;
                }
            }
        }
        cout<<count<<endl;
    }
    return 0;
}
全部评论

相关推荐

做个有文化的流氓:不想当将军的士兵不是好士兵
点赞 评论 收藏
分享
迷茫的大四🐶:当你得到一些东西,那这些东西就会变成基本项,你有别人也有
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务