挖个坑。开始板刷lightoj.
1354 http://www.lightoj.com/volume_showproblem.php?problem=1354
2进制与十进制是否相等。
代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
#include <map>
#include <set>
#include <vector>
using namespace std;
const int MAXN = 101000;
typedef long long LL;
int cases;
char s[MAXN];
LL a, b, c, d, e, num;
char r;
int main()
{
scanf("%d", &cases);
for (int i = 1; i <= cases; i++)
{
scanf("%lld%c%lld%c%lld%c%lld", &a, &r, &b, &r, &c, &r, &d);
scanf("%s", s);
int ok = 1;
///////////// a
e = 0;
num = 0;
for (int i = 7; i >= 0; i--)
{
if (s[i] == '1')
e += pow(2, num);
num++;
}
if (e != a) ok = 0;
//////////////// b
e = 0;
num = 0;
for (int i = 16; i >= 9; i--)
{
if (s[i] == '1')
e += pow(2, num);
num++;
}
if (e != b) ok = 0;
///////////// c
e = 0;
num = 0;
for (int i = 25; i >= 18; i--)
{
if (s[i] == '1')
e += pow(2, num);
num++;
}
if (e != c) ok = 0;
/////////// d
e = 0;
num = 0;
for (int i = 34; i >= 27; i--)
{
if (s[i] == '1')
e += pow(2, num);
num++;
}
if (e != d) ok = 0;
printf("Case %d: ", i);
if (ok) puts("Yes");
else puts("No");
}
return 0;
}
1214 http://www.lightoj.com/volume_showproblem.php?problem=1214
问一个大数是否能被另一个数整除。
代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
using namespace std;
int cases;
int ok;
long long b;
string s;
int main()
{
scanf("%d", &cases);
for (int i = 1; i <= cases; i++)
{
cin >> s;
scanf("%lld",&b);
long long sum = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] == '-') continue;
sum = (sum * 10 + s[i]-'0') % b;
}
printf("Case %d: ", i);
if (!sum) puts("divisible");
else puts("not divisible");
}
return 0;
}
1116 http://www.lightoj.com/volume_showproblem.php?problem=1116
问n是否可以分解为一个奇数和一个偶数的乘积
代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
using namespace std;
typedef long long LL;
LL n, m;
LL ans;
int cases;
int main()
{
scanf("%d", &cases);
for (int i = 1; i <= cases; i++)
{
scanf("%lld", &n);
printf("Case %d: ", i);
LL tmp = 1;
while (n % 2 == 0)
{
n /= 2;
tmp *= 2;
}
if (n % 2 == 1 && tmp != 1)
printf("%lld %lld\n", n, tmp);
else
puts("Impossible");
}
return 0;
}
1294 http://www.lightoj.com/volume_showproblem.php?problem=1294
代码:
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
using namespace std;
typedef long long LL;
LL n, m;
LL ans;
int cases;
int main()
{
cin >> cases;
for (int i = 1; i <= cases;i++)
{
cin >> n >> m;
int t = n / m / 2;
ans = t*m*m;
cout << "Case " << i << ": ";
cout << ans << endl;
}
return 0;
}
1214
http://lightoj.com/volume_showproblem.php?problem=1214
判断大数是否能整除
#include <stdio.h>
#include <ctime>
#include <math.h>
#include <limits.h>
#include <complex>
#include <string>
#include <functional>
#include <iterator>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <bitset>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <iostream>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
using namespace std;
int t;
char s[10000000];
long long n;
int main()
{
scanf("%d",&t);
int cases = 1;
while (t--)
{
scanf("%s %lld",s,&n);
printf("Case %d: ",cases++);
long long ans = 0;
int len = strlen(s);
for (int i = 0; i < len; i++)
{
if (s[i] == '-') continue;
ans = (ans * 10 + s[i] - '0') % n;
}
if (ans == 0)
puts("divisible");
else
puts("not divisible");
}
return 0;
}