A题链接:https://codeforces.com/contest/1036/problem/A

A题AC代码:

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdbool.h>
#include <ctype.h> typedef long long ll; int main()
{
ll n, k, i, j, ans;
while( ~scanf( "%I64d%I64d", &n, &k ) )
{
printf( "%I64d\n", ( k + n - ) / n );
}
return ;
}

B题链接:https://codeforces.com/contest/1036/problem/B

B题AC代码:

 #include <iostream>
#include <cstring>
#include <cstdio> typedef unsigned long long ULL;
typedef const int cint;
typedef long long LL;
using namespace std; int q;
LL n,m,k;
template< typename Q >
void inin(Q &); int main()
{
inin(q);
while( q -- )
{
inin(n);
inin(m);
inin(k);
if( n > m )
swap( n, m );
if( k < m )
printf( "-1" );
else
{
if( n == m )
{
if( ( k-n ) & )
printf( "%I64d", k - );
else
printf( "%I64d", k );
}
else
{
LL temp = m - n;
if( temp & )
printf( "%I64d", k - );
else
{
if( ( k - m ) & )
printf( "%I64d", k - );
else
printf( "%I64d", k );
}
}
}
printf( "\n" );
}
return ;
} template< typename Q >
void inin( Q &x )
{
x=;
int f=;
char ch;
scanf( "%c", &ch );
while( ch < '' || ch > '' )
{
if( ch == '-' )
f = ;
scanf( "%c", &ch );
}
while( ch >= '' && ch <= '' )
{
x = x* + ch - '';
scanf( "%c", &ch );
}
x = f?-x:x;
}

C题链接:https://codeforces.com/contest/1036/problem/C

C题AC代码:

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <malloc.h>
#include <stdbool.h>
#include <ctype.h> typedef long long ll; ll Arr[][];
int dig[];
ll dp( int, int, int );
ll calc(ll); int main()
{
memset( Arr, -, sizeof(Arr) );
int i, T=;
ll L,R;
while( ~scanf( "%d", &T ) )
{
for ( i = ; i <= T; i ++ )
{
scanf( "%I64d%I64d", &L, &R );
L--;
printf( "%I64d\n", calc(R) - calc(L) );
}
}
return ;
} ll dp( int len, int res, int lim )
{
if ( res > )
return ;
if ( len == )
return ;
if ( !lim && Arr[len][res] > )
return Arr[len][res];
ll ret = ;
int up = ;
if (lim)
up=dig[len];
int i;
for ( i = ; i <= up; i ++ )
ret += dp( len-, res+(i>), lim && ( i == up ) );
if (!lim) Arr[len][res]=ret;
return ret;
} ll calc(ll x)
{
int _sum = ;
while (x)
{
dig[ ++ _sum ] = x % ;
x /= ;
}
return dp( _sum, , );
}

全部测过样例再提交,另外,本蒟蒻还从未做过D……

Educational Codeforces Round 50 (Rated for Div. 2)的A、B、C三题AC代码-LMLPHP

05-17 15:50