传送门:
http://codeforces.com/contest/611/problem/A
这题刚开始写的时候是硬算的,由于马虎把星期日算错了,其实直接暴力就ok了
// Days (A), by Errichto
#include<bits/stdc++.h>
using namespace std;
int t[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
int x;
scanf("%d", &x);
char sl[15];
scanf("%s", sl);
scanf("%s", sl);
if(sl[0] == 'w') {
int current = 5;
int ans = 0;
for(int i = 0; i < 366; ++i) {
if(current == x) ++ans;
++current;
if(current > 7) current = 1;
}
printf("%d\n", ans);
return 0;
}
int c = 0;
for(int i = 0; i < 12; ++i) c += x <= t[i];
printf("%d\n", c);
return 0;
}
传送门:
http://codeforces.com/contest/611/problem/B
这道题目我的想法是和标解一样的,但是实际打的时候1个是没写1LL,1个是在用dev的时候用了%64d,坑啊,调试了好长时间,最后是因为这个原因导致输入的r区间刚开始就是错的,
下次调试的时候一定要注意这一点了,中间加上输出也是十分必要的,还有就是有的时候加法和减法一定要挑方便的用,比如这道题就应该用减法,我写的就是分丑陋
// One zero, by Errichto
// O(log^2(n))
#include<bits/stdc++.h>
using namespace std;
int main() {
long long a, b;
scanf("%lld%lld", &a, &b);
int c = 0;
for(int i = 0; (1LL << i) / 2 <= b; ++i)
for(int j = 0; j <= i - 2; ++j) {
long long x = (1LL << i) - 1 - (1LL << j);
c += a <= x && x <= b;
}
printf("%d\n", c);
return 0;
}