toj 2829 cow counting

一开始想多了,以为应该做个数位dp的,后来想了想也不过100W的数据,直接暴力好像也不慢,于是暴力就过了,还挺快。

 1 #include <iostream>
 2 using namespace std;
 3
 4 bool judge( int x, int d )
 5 {
 6     while ( x )
 7     {
 8         int r = x % 10;
 9         if ( r == d ) return false;
10         x = x / 10;
11     }
12     return true;
13 }
14
15 int main ()
16 {
17     int n, d;
18     while ( cin >> n >> d )
19     {
20         int cnt = 1;
21         for ( int i = 1; i <= n; i++ )
22         {
23             while ( !judge( cnt, d ) )
24             {
25                 cnt++;
26             }
27             cnt++;
28         }
29         cout << cnt - 1 << endl;
30     }
31     return 0;
32 }
时间: 2024-08-01 23:38:58

toj 2829 cow counting的相关文章

TOJ 4105 Lines Counting(离线树状数组)

4105.   Lines Counting Time Limit: 2.0 Seconds   Memory Limit: 150000K Total Runs: 152   Accepted Runs: 47 On the number axis, there are N lines. The two endpoints L and R of each line are integer. Give you M queries, each query contains two interval

TOJ 2703: Cow Digit Game

2703: Cow Digit Game Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByte Total Submit: 1            Accepted:1 Description Bessie is playing a number game against Farmer John, and she wants you to help her achieve victory. Game i start

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

【转】对于杭电OJ题目的分类

[好像博客园不能直接转载,所以我复制过来了..] 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDI

转载:hdu 题目分类 (侵删)

转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029. 1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092.1093. 1094.1095.1096.1097.1098.1106.1108.1157.116

TOJ 假题之 Cow Brainiacs

1570: Cow Brainiacs  Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByteTotal Submit: 15            Accepted:8 Description One afternoon as the cows were chewing their cud, Bessie said, "Let's have a contest to see who is the smartest

TOJ 1693:Silver Cow Party(最短路+思维)

描述 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road i requires Ti

bzoj4397【Usaco2015 Dec】Breed Counting

4397: [Usaco2015 dec]Breed Counting Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 29  Solved: 25 [Submit][Status][Discuss] Description Farmer John's N cows, conveniently numbered 1-N, are all standing in a row (they seem to do so often that it now

bzoj4397【Usaco2015 Dec】Breed Counting(前缀和、树状数组)

题目描述 Farmer John's N cows, conveniently numbered 1…N, are all standing in a row (they seem to do so often that it now takes very little prompting from Farmer John to line them up). Each cow has a breed ID: 1 for Holsteins, 2 for Guernseys, and 3 for