标签:
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff;
int main(void) {
//problem: cf#200, address:
int n, y, last = -1, ans = 1;
string x;
cin >> n;
while(n--) {
cin >> x;
if(x == "10") y = 10;
else y = 1;
if(last != -1 && y != last) ans++;
last = y;
}
cout << ans << endl;
return 0;
}
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff;
int main(void) {
//problem:cf#200 , address:
int a, b, c;
cin >> a >> b >> c;
bool ok = false;
for(int i = 0; i <= b; i++) {
if(b - i == c - (a - i)) {
ok = true;
cout << i << " " << b - i << " "<< a - i << endl;
break;
}
}
if(!ok) cout << "Impossible" << endl;
return 0;
}
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff;
LL a, b, ans;
void dfs(LL x, LL y) {
if(y == 0) return;
ans += x / y;
x %= y;
swap(x, y);
dfs(x, y);
}
int main(void) {
//problem: cf#200, address:
cin >> a >> b;
dfs(a, b);
cout << ans << endl;
return 0;
}
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int M = 100009,INF = 0x3fffffff;
int main(void) {
//problem: , address:
char c;
stack<int> s;
while ((c = getchar()) != ‘\n‘) {
int x = (c == ‘+‘ ? 1 : -1);
if(s.empty()) {s.push(x); continue;}
if(x == s.top()) s.pop();
else s.push(x);
}
cout << (s.empty() ? "Yes" : "No") << endl;
return 0;
}
标签:
原文地址:http://blog.csdn.net/jibancanyang/article/details/45974355