ĐÁP ÁN VÒNG 1 CUỘC THI TIN HỌC LẦN 3
Câu 1(2 điểm)
uses crt;
var n,dv,ch:integer;
begin
clrscr;
readln(n);
if (0<=n) and (n<=19) then
begin
case n of
0: write('zero');
1: write('one');
2: write('two');
3: write('three');
4: write('four');
5: write('five');
6: write('six');
7: write('seven');
8: write('eight');
9: write('nine');
10: write('ten');
11: write('eleven');
12: write('twelve');
13: write('thirteen');
14: write('fourteen');
15: write('fifteen');
16: write('sixteen');
17: write('seventeen');
18: write('eighteen');
19: write('nineteen');
end;
end
else
begin
dv:=n mod 10;
ch:=n div 10;
case ch of 2:
write('twenty');
3: write('thirty');
4: write('forty');
5: write('fifty');
6: write('sixty');
7: write('seventy');
8: write('eighty');
9: write('ninety');
end;
if dv>0 then
begin
write('-');
case dv of 1:
write('one');
2: write('two');
3: write('three');
4: write('four');
5: write('five');
6: write('six');
7: write('seven');
8: write('eight');
9: write('nine');
end;
end;
end;
end.
Câu 2(2 điểm)
uses crt;
var a,b,t,bcnn:int64;
begin
readln(a,b);
bcnn:=a*b;
t:=b mod a;
while t<>0 do
begin
t:=a mod b;
a:=b;
b:=t;
end;
bcnn:=bcnn div a;
writeln(a,' ',bcnn);
readln;
end.
Câu 3(4 điểm)
uses crt;
var q,i:longint;
n:array[1..10] of longint;
begin
clrscr;
readln(q);
for i:=1 to q do
readln(n[i]);
for i:=1 to q do
begin
if (n[i] mod 4=0) and (n[i] mod 100<>0) then writeln('YES')
else if n[i] mod 400=0 then writeln('YES')
else writeln('NO');
end;
end.
Câu 4(2 điểm)
uses crt;
var n,p,x,dem:int64;
{----------------------chuong-trinh-con-tim-ucln---------------------}
function ucln(a,b:int64):int64;
var t:int64;
begin
t:=b mod a;
while t<>0 do
begin
t:=a mod b;
a:=b;
b:=t;
end;
ucln:=a;
end;
{---------------------chuong-trinh-chinh---------------------}
begin
readln(n,p);
dem:=0;
for x:=1 to n do
if ucln(x,n)=p then inc(dem);
writeln(dem);
end.
Câu 5(10 điểm) Bài làm của bạn @Hưng Nguyễn Thái
#include<bits/stdc++.h>
using namespace std;
#define ll long long #define mod (ll)(1e7+7)
const ll N = 1000000;
ll lp[N+1];
vector<ll > pr;
void solve()
{ for (ll i=2; i<=N; ++i)
{ if (lp[i] == 0)
{ lp[i] = i; pr.push_back (i);
}
for (ll j=0; j<(ll )pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
lp[i * pr[j]] = pr[j];
}
}
ll po(ll a,ll n)
{ ll res=a, ans=1; while(n)
{ if(n%2) ans=ans*res%mod; res=res*res%mod; n/=2;
}
return ans;
}
ll aka(ll p, ll alpha)
{
if(alpha==0) return 1;
if(alpha==1) return (p+1);
if(alpha%2==1) return p*aka(p,alpha-1)+1;
if(alpha%2==0) return (po(p,alpha/2)+1)*(aka(p,alpha/2)-1)+1;
}
ll f(ll n)
{
ll tmp,i=0,so_mu,res=1;
while(pr[i]<=n)
{
tmp=pr[i];
so_mu=0;
while(tmp<=n)
{
so_mu = so_mu+ (n/tmp);
tmp=tmp*pr[i];
}
res=res*(so_mu+1)*(so_mu+2)/2%mod; i++;
}
return res;
}
int main(){ ll n,res; solve();
while(1)
{
cin>>n;
if(n==0) break;
res=f(n);
cout<<res<<'\n';
}
}
hoa mắt chong mặt, đúng là các thiên tài