Educational Codeforces Round 50 (Rated for Div. 2)的A、B、C三题AC代码
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代码的更多相关文章
- Educational Codeforces Round 50 (Rated for Div. 2) F - Relatively Prime Powers(数学+容斥)
题目链接:http://codeforces.com/contest/1036/problem/F 题意: 题解:求在[2,n]中,x != a ^ b(b >= 2 即为gcd)的个数,那么实 ...
- Educational Codeforces Round 50 (Rated for Div. 2) C. Classy Numbers
C. Classy Numbers 题目链接:https://codeforces.com/contest/1036/problem/C 题意: 给出n个询问,每个询问给出Li,Ri,问在这个闭区间中 ...
- Educational Codeforces Round 50 (Rated for Div. 2)F. Relatively Prime Powers
实际上就是求在[2,n]中,x != a^b的个数,那么实际上就是要求x=a^b的个数,然后用总数减掉就好了. 直接开方求和显然会有重复的数.容斥搞一下,但实际上是要用到莫比乌斯函数的,另外要注意减掉 ...
- Educational Codeforces Round 50 (Rated for Div. 2) E. Covered Points
注释上都有解析了,就不写了吧,去重的问题就用set解决,并且呢第i个线段最多和其他线段产生i-1个交点,n^2logn. #include <cmath> #include <cst ...
- Educational Codeforces Round 76 (Rated for Div. 2) A. Two Rival Students 水题
A. Two Rival Students There are
- Educational Codeforces Round 94 (Rated for Div. 2) A. String Similarity (构造水题)
题意:给你一个长度为\(2*n-1\)的字符串\(s\),让你构造一个长度为\(n\)的字符串,使得构造的字符串中有相同位置的字符等于\(s[1..n],s[2..n+1],...,s[n,2n-1] ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
随机推荐
- c++关键字explicit
关键字explicit,可以阻止不应该允许的经过转换构造函数进行的隐式转换的发生.声明为explicit的构造函数不能在隐式转换中使用. C++中, 一个参数的构造函数(或者除了第一个参数外其余参数都 ...
- PHP读取MySQL数据
方法/步骤 先配置一下数据库: define("DB_HOST","localhost");//数据库地址,一般为localhost define(&q ...
- [已读]响应式web设计实践
薄的一本,彩印,书质量和内容都不错. 响应设计三要素:媒体查询.流动布局.自适应图片.
- 更新项目,uwsgi重新加载和日志文件
uwsgi --reload /var/run/uwsgi.pid uwsgi.pid是uwsgi进程文件 /var/log/uwsgi.log
- Ionic之增加样式会自动换行解决方案
设置样式的时候,引用自身的样式,能正常显示,但是引用自定义样式显示的时候,竟然或自动换行,好尴尬. 原本代码: $('.codeSuccess').css({'display':'block'}); ...
- P1554 梦中的统计
题目背景 Bessie 处于半梦半醒的状态.过了一会儿,她意识到她在数数,不能入睡. 题目描述 Bessie的大脑反应灵敏,仿佛真实地看到了她数过的一个又一个数.她开始注意每一个数码(0..9):每一 ...
- 洛谷P2774 方格取数问题(最小割)
题意 $n \times m$的矩阵,不能取相邻的元素,问最大能取多少 Sol 首先补集转化一下:最大权值 = sum - 使图不连通的最小权值 进行黑白染色 从S向黑点连权值为点权的边 从白点向T连 ...
- Knockout-了解Observable与computed
KO是什么? KO不是万能的,它的出现主要是为了方便的解决下面的问题: UI元素较多,用户交互比较频繁,需要编写大量的手工代码维护UI元素的状态.样式等属性? UI元素之间关系比较紧密,比如操作一个元 ...
- java nio 读取大文件
package com.yao.bigfile; import java.io.File; import java.io.IOException; import java.io.RandomAcces ...
- Navicat工具备份还原mysql数据库详细图解
Navicat是个很不错的MYSQL数据库管理工具,我们常用的还web形式的phpmyadmin和font这三种了,都是非常不错的mysql管理工具.因为Navicat工具兼容性比较好,操作也比较简单 ...