uva 340 A - Master-Mind Hints (暴力)
相关文章
codeforces #519 A A. Multiplication Table (暴力)
·385 字·1 分钟
A. Multiplication Table
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Let’s consider a table consisting of n rows and n columns. The cell located at the intersection of i-th row and j-th column contains number i × j. The rows and columns are numbered starting from 1.
You are given a positive integer x. Your task is to count the number of cells in a table that contain number x.
HUST team contest #2 A An Industrial Spy ||poj 3842 (筛)
·985 字·2 分钟
蠢了。
这道题显然可以搜。。
然后自己搜索的姿势果然还是不怎么地。
最后是蔡大神过掉的。
他的思路是枚举素数,然后把素数的各位拆开,看这些数字是否在给出的字符串中出现过。
一开始TLE掉了。
codeforces 520 A. Pangram (暴力)
·267 字·1 分钟
给一个字符串,问这个字符串中是否26个字母都出现过(大小写只出现一个就算出现过) 开个布尔数组,扫一遍即可。 嘛,做两道水题放松下== 反正也是要清的。
代码实现 1/************************************************************************* 2 > File Name: code/cf/#295/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月17日 星期一 04时05分12秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30const int inf = 0x7fffffff; 31bool v[30]; 32int main() 33{ 34 int n; 35 scanf("%d",&n); 36 memset(v,false,sizeof(v)); 37 string st; 38 cin>>st; 39 for ( int i = 0 ; i < n ; i ++) 40 { 41 if (islower(st[i])) 42 { 43 v[st[i]-'a'] = true; 44 } 45 else 46 { 47 v[st[i]-'A'] = true; 48 } 49 } 50 for ( int i = 0 ; i < 26 ; i++) 51 { 52 if (!v[i]) 53 { 54 55 cout<<"NO"<<endl; 56 return 0; 57 } 58 } 59 cout<<"YES"<<endl; 60 61 return 0; 62}
codeforces 569 C Primes or Palindromes? (暴力)
·475 字·1 分钟
先预处理出来比小于等于n的素数的个数和回文数的个数…
素数不筛竟然也可以过
然后暴力就好.
需要注意的是,比值并不单调,找最大的n,可能之前某个数开始不满足条件,之后又有满足条件的了.
cf 570 C. Replacement (暴力)
·1010 字·3 分钟
C. Replacement
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Daniel has a string s, consisting of lowercase English letters and period signs (characters ‘.’). Let’s define the operation of replacement as the following sequence of steps: find a substring “..” (two consecutive periods) in string s, of all occurrences of the substring let’s choose the first one, and replace this substring with string “.”. In other words, during the replacement operation, the first two consecutive periods are replaced by one. If string s contains no two consecutive periods, then nothing happens.