SZU3
这是第一题,像这种水题一定不要想复杂,思路不对立马换。
抓住串联和并联,可以用辗转相除法
#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);
}
}
这题考看懂题意。。
#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);
}
}
这也是简单题,千万别先往复杂想。只要最后两个数字能被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); }
}
其实可以化成长度为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的更多相关文章
随机推荐
- 打造一款1kb大马并且处理D盾以及安全狗拦截与查杀
在之前sky666提到了关于大马被waf拦的问题,我决定手动去过一下bypass.可是发现怎么也过不去查杀,更别说拦截了.对此无奈,只好花了个通宵去处理一下.顺便一提,理论过所有Waf,并且被杀只需要 ...
- INSERT IGNORE 与INSERT INTO的区别,以及replace的用法
INSERT IGNORE 与INSERT INTO的区别就是INSERT IGNORE会忽略数据库中已经存在 的数据,如果数据库没有数据,就插入新的数据,如果有数据的话就跳过这条数据. 这样就可以保 ...
- [ActionScript 3.0] AS3 弹性运动
package com.views { import flash.display.Sprite; import flash.events.Event; import flash.geom.Point; ...
- mysql高级内容
一. 简介 实体与实体之间有3种对应关系,这些关系也需要存储下来 在开发中需要对存储的数据进行一些处理,用到内置的一些函数 视图用于完成查询语句的封装 事务可以保证复杂的增删改操作有效 二. 关系 创 ...
- java多线程那点事
屌丝程序员们对自己的技术能力总是毫不掩饰的高调,更有甚者每当完成一个简单的功能或算法实现,恨不得从工位上跳起来,生怕谁不知道一样,心情能理解,但个人完全鄙视这种行为.说到底,大家日常的coding,大 ...
- CH2401 送礼物(双向dfs)
CH2401 送礼物 描述 作为惩罚,GY被遣送去帮助某神牛给女生送礼物(GY:貌似是个好差事)但是在GY看到礼物之后,他就不这么认为了.某神牛有N个礼物,且异常沉重,但是GY的力气也异常的大(-_- ...
- React.Children详解
React.Children提供了处理this.props.children的工具,this.props.children可以任何数据(组件.字符串.函数等等).React.children有5个方法 ...
- 提交app时候遇到IDFA警告
1.最近提交app时候遇到如下问题,解决方案: Everything has come to its usual state now. Simply upload your binary as you ...
- html5兼容问题
1.html5对于ie9一下的版本不支持,所以我们可以添加(你可以下载至本地): <!--[if lt IE 9]> <script src="http://cdn.sta ...
- 机器学习中的范数规则化之 L0、L1与L2范数、核范数与规则项参数选择
装载自:https://blog.csdn.net/u012467880/article/details/52852242 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化.我们先简单的来理 ...