# 83 条题解

• @ 2018-03-24 20:40:48
``````#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#define FOR(i,x,y) for(i=x;i<=y;++i)
#define maxa 1000+10
using namespace std;
int a[10];
int main()
{
string s;
cin>>s;
int len = s.length();
if((s[s.length()-1]-'0')%2==0)
a[1] = 1;
else
a[1] = 0;
int sum =0,i;
for(i=0;i<len;++i)
sum+=s[i]-'0';
if(sum%3==0)
a[2] = 1;
else
a[2] = 0;
if(((s[len-2]-'0')*10+s[len-1]-'0')%4==0)
a[3] = 1;
else
a[3] = 0;
if(((s[len-3]-'0')*100+(s[len-2]-'0')*10+s[len-1]-'0')%8==0)
a[4] = 1;
else
a[4] = 0;

if(s[len-1]=='1'||s[len-1]=='4'||s[len-1]=='6'||s[len-1]=='9'||s[len-1]=='0')
a[5] = 1;
else
a[5] = 0;
for(i=1;i<=5;++i)
cout<<a[i]<<endl;
return 0;
}

``````
• @ 2020-04-05 22:38:09
``````s = input()

print(1 - int(s[-1]) % 2)
a3 = 0
for d in s:
a3 += int(d)
print(1 - (a3 % 3 != 0))
print(1 - (int(s[-2:]) % 4 != 0))
print(1 - (int(s[-3:]) % 8 != 0))
print(1 - (s[-1] == '2' or s[-1] == '3' or s[-1] == '7' or s[-1] == '8'))
``````
• @ 2019-01-31 22:48:10

#include <stdio.h>
#include <math.h>
#include <string.h>
int main ()
{
char c[100000];
scanf("%s",c);
int len=strlen(c);
int a=c[len-1]-'0';
int b=(c[len-2]-'0')*10+a;
int d=(c[len-3]-'0')*10+b;
int e=0,i;
for(i=0;i<len;i++)
e+=c[i];
if (a%2==0)
printf("1\n");
else
printf("0\n");
if (e%3==0)
printf("1\n");
else
printf("0\n");
if (b%4==0)
printf("1\n");
else
printf("0\n");
if (d%8==0)
printf("1\n");
else
printf("0\n");
if (a!=2&&a!=3&&a!=7&&a!=8)
printf("1\n");
else
printf("0\n");
}

• @ 2016-06-20 16:29:34

**
末位判断2的倍数
各个位之和判断3的倍数
末两位判断4的倍数
末三位判断5的倍数
末位014569判断完全平方数
**

``````
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
string s;
int x;
int main(){
getline(cin,s);
for(unsigned i = 0;i < s.length();i++) x += s[i] - '0';
if(s[s.length() - 1] & 1) printf("0\n");
else printf("1\n");
if(x % 3 == 0)printf("1\n");
else printf("0\n");
if((s[s.length() - 1] - '0' + (s[s.length() - 2] - '0') * 10) % 4 == 0) printf("1\n");
else printf("0\n");
if((s[s.length() - 1] - '0' + (s[s.length() - 2] - '0') * 10 + (s[s.length() - 3] - '0') * 100) % 8 == 0) printf("1\n");
else printf("0\n");
if(s[s.length() - 1] == '0' || s[s.length() - 1] == '1' || s[s.length() - 1] == '4' || s[s.length() - 1] == '5' || s[s.length() - 1] == '6' || s[s.length() - 1] == '9') printf("1\n");
else printf("0\n");
return 0;
}

``````
• @ 2015-09-30 14:51:45

题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题水水水水题题题题题
题题题题题题题题题题题题题题题题题题题题题题题题水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水水水水水水水水水水题题题题题题
题题题题题题题题题题题水水水水题水水水水水水水水水水水题题题题题题题题题题
题题题题题题题题水水水水水水水题水水水题题水水水水水题题题题题题题题题题题
题题题水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水水水题题题题题题水水水水题题题题题题题题题题题题
题水水水水水水水水水水水水题题题题题题题水水水水水水水水水水水题题题题题题
题水水水水水水水水水水水水题题题题题题水水水水水水水水水水水水水水题题题题
题题水水水水水水水水水水题题题题题水水水水水水题题题水水水水水水水题题题题
题题题题题题题题水水水水题题题题题水水水水题题题题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水题题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水水题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题题水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水水题水水水水题题水水水水水题题题题题
题题题题题题题题水水水水题题题题水水水题题水水水水题题水水水水水题题题题题
题题水水题题题水水水水水题题题题水水水题题水水水题题题水水水水水题题题题题
题题水水水水水水水水水水题题题题题水水题题水水题题题题水水水水水题题题题题
题题题水水水水水水水水水题题题题题题题题水水水题题题题水水水水题题题题题题
题题题题题水水水水水水水题题题题题题题题水水水题水水水水题题题题题题题题题
题题题题题题水水水水水水题题题题题题题水水水水题题水水水水题题题题题题题题
题题题题题题题题题水水水题题题题题题水水水水水题题题水水水水水水水题题题题
题题题题题题题题题题题题题题题题水水水水水水题题题题题水水水水水水题题题题
题题题题题题题题题题题题题题题水水水水水水题题题题题题水水水水水水水题题题
题题题题题题题题题题题题题题水水水水水题题题题题题题题题水水水水水水题题题
题题题题题题题题题题题题题水水水水水题题题题题题题题题题题水水水水题题题题
题题题题题题题题题题题题水水水题题题题题题题题题题题题题题题水水水题题题题
题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题题

• @ 2016-12-20 17:43:48

我操。。。。。数组一定要开大。。。rte 两次 百度发现开大数组 然后ac

• @ 2016-08-16 20:53:57

#include<iostream>
#include<cstring>
using namespace std;
char a[1000];
int ein=1,zwei=0;
long int gw=0;
int main()
{
cin>>a;
int len=strlen(a);
if((a[len-1]-'0')%2==0)
cout<<ein;
else
cout<<zwei;
cout<<endl;
for(int i=0;i<len;i++)
gw+=a[i]-'0';
if(gw%3==0)
cout<<ein;
else
cout<<zwei;
cout<<endl;
if(((a[len-2]-'0')*10+a[len-1]-'0')%4==0)
cout<<ein;
else
cout<<zwei;
cout<<endl;
if(((a[len-3]-'0')*100+(a[len-2]-'0')*10+a[len-1]-'0')%8==0)
cout<<ein;
else
cout<<zwei;
cout<<endl;
if(a[len-1]=='1'||a[len-1]=='4'||a[len-1]=='6'||a[len-1]=='9'||a[len-1]=='0')
cout<<ein;
else
cout<<zwei;
return 0;
}

• @ 2015-08-24 17:51:32

#include<iostream>
#include<string>
#include<set>
using namespace std;

int main() {
string s; cin>>s;
cout<<!(int(s[s.size()-1]-'0')%2)<<endl;
int sum=0;
for (int i=0;i<s.size();++i) sum+=s[i]-'0';
cout<<!(sum%3)<<endl;
sum=0;
for (int i=(s.size()-2<0?0:s.size()-2);i<s.size();++i) sum=sum*10+(s[i]-'0');
cout<<(!(sum%4))<<endl;
for (int i=(s.size()-3<0?0:s.size()-3);i<s.size();++i) sum=sum*10+(s[i]-'0');
cout<<(!(sum%8))<<endl;
set<char> p={'2','3','7','8'};
cout<<(!(p.count(s[s.size()-1])));
return 0;
}

• @ 2015-08-04 11:16:29

#include<cstdio>
#include<cstring>
int main()
{
char a[1000];
int i,len,temp=0;
gets(a);
len=strlen(a);

if( (a[len-1]-'0') %2==0 )
printf("1\n");
else printf("0\n");

for(i=0;i<len;i++)
{
temp=temp+a[i]-'0';
}
if(temp%3==0)

printf("1\n");
else printf("0\n");

if( ( (a[len-2]-'0') *10 + a[len-1]-'0')%4==0 )
printf("1\n");
else printf("0\n");

if( ( (a[len-3]-'0') *100 + (a[len-2]-'0') *10 + a[len-1]-'0')%8==0 )
printf("1\n");
else printf("0\n");

if( a[len-1]=='1' || a[len-1]=='4' || a[len-1]=='6' || a[len-1]=='9' || a[len-1]=='0' )
printf("1");
else printf("0");

return 0;
}

• @ 2015-05-11 10:24:54

为什么开35不行 破题 应该行啊

#include<stdio.h>
#include<string.h>
int main()
{
char s[100003];
int l,i,n[100030],f,sum,a4,a8;
while(~scanf("%s",s))
{
f=0,sum=0,a4=a8=0;
l=strlen(s);
for(i=0;i<l;i++)
{
n[i]=s[i]-'0';
a4=a4*10+n[i];
a4%=4;
a8=a8*10+n[i];
a8%=8;
sum+=n[i];
}
if(n[l-1]%2==0)
{
printf("1\n");
f++;
}
else
printf("0\n");
if(sum%3==0)
{
printf("1\n");
f++;
}
else
printf("0\n");
if(a4==0)
{
printf("1\n");
f++;
}
else
printf("0\n");
if(a8==0)
{
printf("1\n");
f++;
}
else
printf("0\n");
if(n[l-1]==0||n[l-1]==1||n[l-1]==4||n[l-1]==5||n[l-1]==6||n[l-1]==9)
printf("1\n");
else
printf("0\n");
}
return 0;
}

• @ 2015-02-10 13:02:17

首先，看了别人的题解，我知道了被4整除只需要看后2位，因为100肯定被4整除；
被8整除只需要看后3位，因为1000肯定被8整除。
而我做时却是用除法求余数。
其次，完全平方数个位必然是0,1,4,5,6,9.而这道题不需要考虑这个，题的难度对于不知道此规律的人就减小了。
而对于知道此规律的人难度反而加大了。
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

int a[10003];
int size;
int div(int k){
int i;
int d = 0;
for (i = size; i >= 0; i--){
d *= 10;
d += a[i];
d %= k;
}
return d;
}
int main(){
freopen("in.txt", "r", stdin);

char s[10003];
cin >> s;
int i;
for (i = 0; s[i]; i++);
size = i;
for (i--; i >= 0; i--)a[size - i - 1] = s[i] - '0';
if (a[0] % 2==0)cout << 1 << endl;
else cout << 0 << endl;
int sum = 0;
for (i = 0; i < size; i++)sum += a[i];
if (sum % 3 == 0)cout << 1 << endl;
else cout << 0 << endl;
if (div(4) != 0)cout << 0 << endl;
else cout << 1 << endl;
if (div(8) != 0)cout << 0 << endl;
else cout << 1 << endl;
cout << 1 << endl;
return 0;
}

• @ 2014-10-22 19:30:19

这题简直逗，f[5]恒为1……
var a:array[1..10000] of longint;
f:array[1..5] of longint;
n,k,i,j,p,q:longint;
s:ansistring;
begin
n:=length(s);
for i:=1 to n do
a[i]:=ord(s[n-i+1])-ord('0');
if a[1] mod 2=0 then f[1]:=1 else f[1]:=0;
k:=0;
for i:=1 to n do
begin
k:=k+a[i];
end;
if k mod 3=0 then f[2]:=1 else f[2]:=0;
p:=a[1]+10*a[2];
if p mod 4=0 then f[3]:=1 else f[3]:=0;
q:=a[1]+10*a[2]+100*a[3];
if q mod 8 =0 then f[4]:=1 else f[4]:=0;

f[5]:=1;
for i:=1 to 5 do
writeln(f[i]);
end.

• @ 2014-08-11 00:30:05

坑题
s[1] in [0,1,4,5,6,9]来判断完全平方
program p1490;
var a,b:array[0..31000] of longint;
n,i,k,t,t1,t2:longint;
s:ansistring;
//
function make(p:longint):longint;
var i:longint;
begin
a:=b;
for i:=a[0] downto 2 do
begin
a[i-1]:=a[i-1]+10*(a[i] mod p);
a[i]:=a[i] div p;
end;
if a[1] mod p=0 then exit(1)
else exit(0);
end;
//
begin
a[0]:=length(s);
for i:=1 to length(s) do a[i]:=ord(s[i])-ord('0');
for i:=1 to a[0] div 2 do begin k:=a[i];a[i]:=a[a[0]+1-i];a[a[0]+1-i]:=k;end;
b:=a;
t:=make(2);t1:=t;writeln(t);
t:=make(3);writeln(t);
t:=make(4);t2:=t;writeln(t);
t:=make(8);writeln(t);
if b[1] in [0,1,4,5,6,9] then write(1)
else write(0);
end.

• @ 2014-01-03 11:33:57

#include <stdio.h>
#include <string.h>

char s[33];

void dv(int x)
{
printf("%d\n" , x);
}

int main()
{
scanf("%s" , s);

int ilen = strlen(s) , i , sum = 0;

if(s[ilen - 1] % 2 == 0) dv(1);
else dv(0);
for(i = 0 ; i < ilen ; i ++ )
{
sum += s[i] - '0';
}
if(sum % 3 == 0) dv(1);
else dv(0);
if((s[ilen - 1] - '0' + (s[ilen - 2] - '0') * 10) % 4 == 0) dv(1);
else dv(0);
if((s[ilen - 1] - '0' + (s[ilen - 2] - '0') * 10 + (s[ilen - 3] - '0') * 100) % 8 == 0) dv(1);
else dv(0);
if(s[ilen - 1] == '0' || s[ilen - 1] == '1' || s[ilen - 1] == '4' || s[ilen - 1] == '9' || s[ilen - 1] == '6' || s[ilen - 1] == '5') dv(1);
else dv(0);
return 0;
}
如何秒杀？

• @ 2014-01-03 11:33:24

编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 436 KiB, score = 20
测试数据 #1: Accepted, time = 0 ms, mem = 436 KiB, score = 20
测试数据 #2: Accepted, time = 15 ms, mem = 436 KiB, score = 20
测试数据 #3: Accepted, time = 0 ms, mem = 440 KiB, score = 20
测试数据 #4: Accepted, time = 0 ms, mem = 440 KiB, score = 20
Accepted, time = 15 ms, mem = 440 KiB, score = 100

• @ 2013-07-31 16:20:35

AC的第90题

• @ 2012-10-15 10:53:35

BS出题人

我开1..32的数组和string怎么改都过不去，最后一怒之下开了个1..10000的数组和ansistring结果AC了

再写题的小心了！

{

ID:darkgod-z

PROG:vijos P1490

HANG:Pascal

}

var

a:array [1..10000] of integer;

i,sum,n:integer;

s:ansistring;

begin

n:=length(s);

for i:=1 to n do

a[i]:=ord(s[n-i+1])-ord('0');

if a[1] mod 2=0 then writeln('1') else writeln('0');

sum:=0;

for i:=1 to n do inc(sum,a[i]);

if sum mod 3=0 then writeln('1') else writeln('0');

if (a[2]*10+a[1]) mod 4=0 then writeln('1') else writeln('0');

if (a[3]*100+a[2]*10+a[1]) mod 8=0 then writeln('1') else writeln('0');

writeln('1');

end.

• @ 2010-07-09 08:50:32

强烈质疑这道题的正确性……

• @ 2009-11-09 21:20:17

纪念我的AC100题...

那个可能的确Nice...

可能，无限可能...

• @ 2009-11-09 21:19:38

晒晒~~

var i,sum:longint;

s:string;

a:array[1..10000] of longint;

procedure reed;

var i,l:longint;

begin

l:=length(s);

sum:=0;

for i:=1 to l do

begin

a[i]:=ord(s[i])-ord('0');

sum:=sum+a[i];

end;

if a[l] mod 2 =0 then writeln(1) else writeln(0);

if sum mod 3 =0 then writeln(1) else writeln(0);

if (a[l-1]*10+a[l]) mod 4 =0 then writeln(1) else writeln(0);

if (a[l-2]*100+a[l-1]*10+a[l]) mod 8=0 then writeln(1) else writeln(0);

writeln(1);

end;

begin

reed;

end.

ID
1490

3

(无)

1126

584

52%

2