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. [ActionScript 3.0] 处理xml内容换行时行间距较大问题的一种简单方法

    我们一定遇到过这种情况,在读取xml里的文章内容时,一旦有换行的位置在flash里显示出来的行间距会比较大,而并非我们想要的效果,解决这个问题的方法除了使用正则表达式以外,这里介绍一种比较简单的方法, ...

  2. CentOS安装搭建zookeeper

    原文连接:https://www.cnblogs.com/rwxwsblog/p/5806075.html zookeeper集群搭建(三台) 注意关闭机器防火墙! 配置ip别名:编辑文件  # /e ...

  3. UITableView定制左滑效果

    UITableViewRowAction类 object defines a single action to present when the user swipes horizontally in ...

  4. 闭包(Closure)和匿名函数(Anonymous function)/lambda表达式的区别

    闭包(Closure)和匿名函数(Anonymous function)/lambda表达式的区别 函数最常见的形式是具名函数(named function): function foo(){ con ...

  5. 吴裕雄 python 机器学习——K均值聚类KMeans模型

    import numpy as np import matplotlib.pyplot as plt from sklearn import cluster from sklearn.metrics ...

  6. Thread类和Runnable接口的比较

    Thread和Runnable的联系 Thread类的定义: public class Thread extends Object implements Runnable 联系:从Thread类的定义 ...

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

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

  8. maven 可执行jar maven-shade-plugin

    <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> ...

  9. BellmanFord贝尔曼-福特算法

    import java.util.ArrayList; import java.util.Scanner; /** * 贝尔曼-福特算法 * * Bellman - ford算法是求含负权图的单源最短 ...

  10. Windows USB 编程

    GUID #include <initguid.h> // For DEFINE_GUID // Device Interface GUID.DEFINE_GUID(GUID_DEVINT ...