Skip to content

Instantly share code, notes, and snippets.

@FooBarrior
Created May 29, 2012 21:35
Show Gist options
  • Save FooBarrior/2830911 to your computer and use it in GitHub Desktop.
Save FooBarrior/2830911 to your computer and use it in GitHub Desktop.
pt
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long LL;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
string s, t;
cin >> s >> t;
int j = 0, sum = 0;
for(int i = 0; i < s.length(); i++){
for(j; j < t.length(); j++)
if(s[i] == t[j]){
j++;
sum++;
break;
}
}
if(sum != s.length()) cout << "NO";
else cout << "YES";
return 0;
}
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
const int simples[168] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
typedef long long LL;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
LL n, m = 1;
cin >> n;
for(int i = 0; i < 168; i++){
LL a = 1;
while(n % simples[i] == 0){
n /= simples[i];
a++;
}
m *= a;
}
cout << m;
return 0;
}
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long LL;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
long long h, w, res = 0;
cin >> h >> w;
cout << w * (w+1) * h * (h+1) / 4;
return 0;
}
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;
typedef long long LL;
int main(){
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n, m, k, r;
cin >> n >> m >> k;
r = n * m;
if(r % k){
cout << -1;
return 0;
}
int i = 0;
for(int j = 0; j < n; j++){
for(int o = 0; o < m; o++){
cout << i / k + 1 << " ";
i++;
}
cout << endl;
j++;
if(j >= n) break;
for(int o = m-1; o >= 0; o--){
cout << i / k + 1 << " ";
i++;
}
cout << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment