CodeForces 343A

这是第一题,像这种水题一定不要想复杂,思路不对立马换。

抓住串联和并联,可以用辗转相除法

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int main()
{
long long a,b;
while(sf("%I64d%I64d",&a,&b)==)
{
long long cnt=;
while(a&&b)
{
if(a>b)
{
cnt+=a/b;
a%=b;
}
else
{
cnt+=b/a;
b%=a;
}
}
pf("%I64d\n",cnt);
}
}

CodeForces - 289A

这题考看懂题意。。

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int main()
{
int n,k;
while(sf("%d%d",&n,&k)==)
{
int sum =;
for(int i =;i<n;i++)
{
int a,b;
sf("%d%d",&a,&b);
sum+=b-a+;
}
pf("%d\n",(k-sum%k)%k);
}
}

CodeForces 628B

这也是简单题,千万别先往复杂想。只要最后两个数字能被4整除,则这个数字就能被4整除,所以枚举最后两个数字就行

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int main()
{
char a[];
while(sf("%s",a)==)
{
int len = strlen(a);
LL cnt=;
for(int i = ;i<len-;i++)
{
int sum = (a[i]-'')*+a[i+]-'';
if(sum%==)
cnt+=i+;
}
for(int i = ;i<len;i++)
{
int sum = a[i]-'';
if(sum%==)
cnt++;
}
pf("%I64d\n",cnt); }
}

codeforces 459C

其实可以化成长度为d的k进制的全排列

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <cctype>
#include <vector>
#include <iterator>
#include <set>
#include <map>
#include <sstream>
using namespace std; #define mem(a,b) memset(a,b,sizeof(a))
#define pf printf
#define sf scanf
#define spf sprintf
#define pb push_back
#define debug printf("!\n")
#define INF 10000
#define MAXN 5010
#define MAX(a,b) a>b?a:b
#define blank pf("\n")
#define LL long long
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define pqueue priority_queue int num[],mp[][];
int n,k,d; int main()
{
while(sf("%d%d%d",&n,&k,&d)==)
{
mem(num,);
mem(mp,);
if(n>pow((double)k,(double)d))
{
pf("-1\n");
continue;
}
for(int i =;i<n;i++)
{
int t = d-;
num[t]++;
while(num[t]==k)
{
num[t]=;
num[t-]++;
t--;
}
memcpy(mp[i],num,sizeof(num));
}
for(int i = ;i<d;i++)
{
for(int j = ;j<n;j++)
pf("%d ",mp[j][i]+);
blank;
}
}
}

SZU3的更多相关文章

随机推荐

  1. [ActionSprit 3.0] FMS远程共享

    package { import flash.display.Sprite; import flash.events.NetStatusEvent; import flash.events.SyncE ...

  2. [转] 以普通用户启动的Vim如何保存需要root权限的文件

    [转] 以普通用户启动的Vim如何保存需要root权限的文件 在Linux上工作的朋友很可能遇到过这样一种情况,当你用Vim编辑完一个文件时,运行:wq保存退出,突然蹦出一个错误: E45: 'rea ...

  3. css中的block与none

    *{ display:none; } div{ display:block; } div 会正常显示粗来吗?不会 因为*代表所有元素,包括div的父级元素html,body 父级元素都不显示了,子元素 ...

  4. dw cs6设置字体样式

    1 编辑->首选参数->字体 改代码试图的字体和大小.点确定即可.

  5. vue混入函数问题

    vue开发时,遇到个问题, import mxTable from "#mixin/table"; 导入了一个混入mxTable,但是该混入函数中import了其他的js代码,此时 ...

  6. [转] Ansible 进阶 | facts 缓存

    [From] https://blog.csdn.net/bruce_6/article/details/81328975 什么是 Ansible factsAnsible facts 是远程系统的信 ...

  7. 论文阅读 | RefineDet:Single-Shot Refinement Neural Network for Object Detection

    论文链接:https://arxiv.org/abs/1711.06897 代码链接:https://github.com/sfzhang15/RefineDet 摘要 RefineDet是CVPR ...

  8. git获取代码,拉取最新代码,更新代码等

    有句话说的很好:git是弓,我们的代码是箭,github就是靶子.我们需要把自己的代码存放到github的仓库上. 下图为截取的阮一峰博客的关于git常用命令总结的一张图片: 1.一开始从零获取代码 ...

  9. vue打包后出现的.map文件

    run dev build 打包项目后出现的list中的".map"文件最大. “.map”文件的作用:项目打包后,代码都是经过压缩加密的,如果运行时报错,输出的错误信息无法准确得 ...

  10. Java 继承学习

    Java 继承 继承实现: 在Java中,如果实现继承的,需要使用Java关键字——extends : 被继承的类叫做超类,继承超类的类叫子类.(一个子类亦可以是另一个类的超类) class 子类 e ...