这套题有点懒得写题解了,,,看代码基本上都能看懂,,,,
697A:Pineapple Incident
#include <cstdio>
int t, x, s;
int main () {
scanf("%d %d %d", &t, &s, &x);
if (x < t) printf("NO");
else if (x == t) printf("YES");
else if (x > t && x < t + s) printf("NO");
else {
int cur = (x - t) % s;
if (cur == 0 || cur == 1) printf("YES");
else printf("NO");
}
return 0;
}
697B:Barnicle:
#include <cstdio>
#include <cstring>
#include <algorithm>
char s[1010000];
bool f = 0; // f = 1 means a is real
int cur = 0;
int cure = 0;
int b;
int main () {
gets(s);
int len = strlen(s);
for (int i = 0; i < len; i++) {
if (s[i] == '.') {
f = 1;
cur = i;
}
if (s[i] == 'e') {
cure = i;
}
}
b = atoi(&s[cure+1]);
if (b == 0) {
if (s[cur+1] == '0' && s[cur+2] == 'e') {
for (int i = 0; i < cur; i++) printf("%c", s[i]);
exit(0);
}
for (int i = 0; i < cure; i++) printf("%c", s[i]);
exit(0);
}
// printf("%d", b);
if (cure - cur - 1 > b) {
int k = cur + b;
int ttt = k;
for (int i = 0; i <= k; i++)
if (s[i] != '0' && s[i] != '.') {
ttt = i;
break;
}
for (int i = ttt; i <= k; i++)
if (s[i] >= '0' && s[i] <= '9') printf("%c", s[i]);
printf(".");
for (int i = k + 1; i < cure; i++) printf("%c", s[i]);
} else {
int ttt = 0;
for (int i = 0; i < cure; i++) {
if (s[i] != '0' && s[i] != '.') {
ttt = i;
break;
}
}
for (int i = ttt; i < cure; i++)
if (s[i] >= '0' && s[i] <= '9') printf("%c", s[i]);
int k = b - cure + cur + 1;
while (k--) printf("0");
}
return 0;
}
697C:Lorenzo Von Matterhorn:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
std :: map<long long, long long> mp;
int q;
int od;
long long x, y, z;
void change(long long x, long long y, long long z) {
if (x < y) std :: swap(x, y);
while (x != y) {
mp[x] += z;
x = x >> 1;
if (x < y) std :: swap(x, y);
}
}
long long xfind(long long x, long long y) {
long long ans = 0;
if (x < y) std :: swap(x, y);
while (x != y) {
ans += mp[x];
x = x >> 1;
if (x < y) std :: swap(x, y);
}
return (ans);
}
int main () {
scanf("%d", &q);
for (int i = 1; i <= q; i++) {
scanf("%d %I64d %I64d", &od, &x, &y);
if (od == 1) {
scanf("%I64d", &z);
change(x, y, z);
} else {
printf("%I64d\n", xfind(x, y));
}
}
return 0;
}