数论基础
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;
ll su[ 10010 ] ;
bool issu[ 10010 ] ;
#define N 10000
ll Pow ( int a, int b)
{
int base = a;
ll ans = 1 ;
while ( b)
{
if ( b& 1 ) ans* = base;
base * = base;
b>> 1 ;
}
return ans;
}
bool isPrime ( int a)
{
if ( a == 1 ) return false ;
if ( a == 2 || a == 3 || a == 5 ) return true ;
if ( a% 2 == 0 || a% 3 == 0 ) return false ;
for ( int i= 5 ; i* i<= a; i+ = 6 )
{
if ( a% i == 0 || a% ( i+ 2 ) == 0 )
return false ;
}
return true ;
}
ll Prime ( ll n)
{
ll cnt = 0 ;
for ( ll i= 2 ; i<= n; i++ ) {
if ( ! issu[ i] )
su[ ++ cnt] = i;
for ( ll j = 1 ; j<= n&& su[ j] * i<= n; j++ ) {
issu[ su[ j] * i] = 1 ;
if ( i% su[ j] == 0 ) break ;
}
}
return cnt;
}
int gcd ( int a, int b)
{
return b== 0 ? a: gcd ( b, a% b) ;
}
int icm ( int a, int b)
{
return a/ gcd ( a, b) * b;
}
int huiwen ( int n)
{
int m = n, t = 0 ;
while ( m)
{
t = t* 10 + m% 10 ;
m/ = 10 ;
}
return n== m? 1 : 0 ;
}
void zhiyinsu ( ll n)
{
Prime ( n) ;
ll i = 1 ;
ll cnt = 0 ;
while ( n != n)
{
if ( n% i == 0 ) {
printf ( "%d " , su[ i] ) ;
cnt++ ;
if ( cnt == 10 ) {
printf ( "\n" ) ;
cnt = 0 ;
}
n/ = su[ i] ;
continue ;
}
i++ ;
}
}
int main ( )
{
zhiyinsu ( N) ;
return 0 ;
}
#include <iostream>
#include <string>
using namespace std;
int mon[ ] = { 0 , 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 } ;
int cntD, cntM, cntW, cnt;
int ans, y = 2000 , m = 1 , d = 1 , week = 6 ;
int main ( )
{
while ( 1 )
{
cntD++ ;
if ( d == 1 ) cntM++ ;
if ( week == 1 ) cntW++ ;
if ( d == 1 && week == 1 ) cnt++ ;
if ( d == 1 || week == 1 ) ans+ = 2 ;
else ans++ ;
if ( y == 2020 && m == 10 && d == 1 ) break ;
if ( ( y% 4 == 0 && y% 100 != 0 ) || y% 400 == 0 ) mon[ 2 ] = 29 ;
else mon[ 2 ] = 28 ;
if ( d == mon[ m] ) {
if ( m == 12 ) {
m = 1 ;
d = 1 ;
y++ ;
}
else {
m++ ;
d = 1 ;
}
}
else d++ ;
if ( week == 7 ) week = 1 ;
else week++ ;
}
cout<< cntD<< endl;
cout<< cntM<< endl;
cout<< cntW<< endl;
cout<< cnt<< endl;
cout<< ans<< endl;
}