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. leetcode-806-Number of Lines To Write String

    题目描述: We are to write the letters of a given string S, from left to right into lines. Each line has ...

  2. HTML-基础及一般标签

    HTML        内容 Hyper Text Markup Language  超文本标记语言(包含文本.表格.图片.声音.视频等,同时也是文档) HTML 元素指的是从开始标签(start t ...

  3. 【Leetcode】Reorder List

    Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do thi ...

  4. ionic基础知识

    ion-header-bar(头部 页眉) 在内容顶部添加一个固定header栏. 用法 <ion-header-bar align-title="left" class=& ...

  5. POJ_3468 A Simple Problem with Integers 【线段树区间查询+修改】

    一.题目 POJ3468 二.分析 裸的线段树区间查询+修改. 三.AC代码 #include <cstdio> #include <iostream> #include &l ...

  6. window.load方法 (加载全部图片,第三方网站时使用)

    $(window).load(  function(){                                                              console.lo ...

  7. oracle12c之一 控制-PDB的磁盘I/O(IOPS,MBPS)资源管理

    在以前的版本中,没有简单的方法来控制单个PDB使用的磁盘I / O量. 因此,某个PDB可能耗尽大量磁盘I / O,并影响同一实例中的其他PDB的性能. Oracle 12c R2可以控制PDB使用的 ...

  8. MongoDB wiredTiger存储引擎下的存储方式LSM和B-Tree比较

    前段时间做拦截件监控的时候把拦截件生命期存入mongodb,因生命期有各种变化,因此对此表的更新写操作非常多,老大给我看了一篇文章,才知道mongodb已经支持lsm存储方式了. 原文如连接:http ...

  9. Java/Android 网络请求框架/库

    Android 图片缓存框架  最上面的最优先 com.facebook.fresco:fresco:0.12.0                7.26.2016最新 Universal-Image ...

  10. Rational Rose2007下载和安装

    网上关于Rational Rose2007安装包,网上找了一堆大多都是垃圾,最后找到一个可用的(带激活文件),保存在自己的网盘里,这里分享出来:https://pan.baidu.com/s/1bpb ...