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的更多相关文章
随机推荐
- 【后缀数组之height数组】
模板奉上 int rank[maxn],height[maxn]; void calheight(int *r,int *sa,int n) { ; ;i<=n;i++) rank[sa[i]] ...
- 使用concat做字符串拼接和数据迁移
作用: 解决一开始数据库建立不合理造成的字段冗余,从而提取部分字段,数据迁移.拼接字符串的功能. 格式: concat(字段1,'间隔符',字段2....) concat_ws('间隔符',字段1,字 ...
- objectARX 添加线型下拉组合框空间 CAcUiLineTypeComboBox
不知道是有意还是无意,objectARX的所有文档中,居然没有CAcUiLineTypeComboBox, 而实际上这个是存在的.位于\inc\acuiComboBox.h 而在添加变量的向导中也没有 ...
- 手把手教你在Mac中搭建iOS的 React Native环境
准备工作 1.你需要一台Mac电脑..(这不是废话?我所用的是Air~~穷..) 2.我所操作的电脑系统环境是 3.xcode版本:8.0正式版 必需的软件 1.Homebrew Homebrew, ...
- Schema Workbench 启动慢
原始是JDBC连接设定的时候需要在参数中增加下列选项 FILTER_SCHEMA_LIST 官方的解释是 就是去搜寻连接数据库的所有的表结构,表越大越慢. 也要把这选项去除,保存数据库链接,并重新登录 ...
- 吴裕雄 python 机器学习——聚类
import numpy as np import matplotlib.pyplot as plt from sklearn.datasets.samples_generator import ma ...
- logo back 日志 发送邮件
<?xml version="1.0" encoding="UTF-8"?> <configuration> <!--<pr ...
- python之类与对象(3)
4. 类的初始化函数__init__(): 本章参考:https://blog.csdn.net/hellocsz/article/details/82795514 原作者: hellocsz 总结 ...
- python全栈开发_day9_脚本文件和函数的基本运用
一:脚本文件 1)脚本文件的操作 import sys p=sys.argv print(p) #将python代码放到cmd中运行,在后面添加参数,会自动保存在输出的列表中,默认输出的列表中只有一个 ...
- Java中的RSA加解密工具类:RSAUtils
本人手写已测试,大家可以参考使用 package com.mirana.frame.utils.encrypt; import com.mirana.frame.utils.log.LogUtils; ...