ural 2065. Different Sums
2065. Different Sums
Memory limit: 64 MB
Input
Output
Samples
input | output |
---|---|
1 1 |
-987654 |
3 2 |
0 7 0 |
Notes
Problem Source: Ural Regional School Programming Contest 2015
/**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mk make_pair inline int getInt()
{
int ret = ;
char ch = ' ';
bool flag = ;
while(!(ch >= '' && ch <= ''))
{
if(ch == '-') flag ^= ;
ch = getchar();
}
while(ch >= '' && ch <= '')
{
ret = ret * + ch - '';
ch = getchar();
}
return flag ? -ret : ret;
} int n, k;
deque<int> ans; inline void input()
{
cin >> n >> k;
k--;
} inline void solve()
{
for(int i = ; * i <= k; i++)
if(i & ) ans.puf(-i), ans.pub(i);
else ans.puf(i), ans.pub(-i);
if(k & ) ans.pub((((k / ) & ) ? - : ) * (k / + ));
for(int i = k / + ; i <= n; i++)
ans.pub();
for(int i = ; i < n - ; i++) cout << ans[i] << ' ';
cout << ans[n - ] << "\n";
} int main()
{
ios::sync_with_stdio();
input();
solve();
return ;
}
ural 2065. Different Sums的更多相关文章
- URAL 2065 Different Sums (找规律)
题意:构造一个数列,使得它们的区间和的种类最少,其中数列中不同的数的数目不少于k. 析:我们考虑0这个特殊的数字,然后0越多,那么总和种类最少,再就是正负交替,那么增加0的数量. 代码如下: #pra ...
- 【找规律】URAL - 2065 - Different Sums
就让0出现得尽可能多嘛……大概感受一下就是这样…… 0 0 ... 0 0 0 0 4 -4 3 -3 2 -2 1 -1 #include<cstdio> using namespace ...
- URAL - 2065 Different Sums (思维题)
题意: 给n和k,让你用不小于 k 个不同的数字构成一个长度为n的序列,使得序列中不同的区间和的数目最小. n,k<=500 k-1个数填一些数字的一正一负,这样有些区间和为0. 剩下的都填0. ...
- ural 1217. Unlucky Tickets
1217. Unlucky Tickets Time limit: 1.0 secondMemory limit: 64 MB Strange people live in Moscow! Each ...
- Poj OpenJudge 百练 2602 Superlong sums
1.Link: http://poj.org/problem?id=2602 http://bailian.openjudge.cn/practice/2602/ 2.Content: Superlo ...
- [LeetCode] Find K Pairs with Smallest Sums 找和最小的K对数字
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define ...
- UVA-11997 K Smallest Sums
UVA - 11997 K Smallest Sums Time Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & ...
- POJ3187Backward Digit Sums[杨辉三角]
Backward Digit Sums Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6350 Accepted: 36 ...
- ural One-two, One-two 2
One-two, One-two 2 Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u ...
随机推荐
- python基础——装饰器
python基础——装饰器 由于函数也是一个对象,而且函数对象可以被赋值给变量,所以,通过变量也能调用该函数. >>> def now(): ... print('2015-3-25 ...
- 【翻译十九】-java之执行器
Executors In all of the previous examples, there's a close connection between the task being done by ...
- Swing布局基础
虽然很简单,但还是记录一下,以备复查. 1.BorderLayout ,这是JFrame的默认布局方式,基于此的新组件,例如BUTTON,可以放在东西南北中的某一个位置,如果不指定,则默认是中央.中央 ...
- git push 使用总结
git push命令用于将本地分支的更新,推送到远程主机.它的格式与git pull命令相仿. $ git push <远程主机名> <本地分支名>:<远程分支名> ...
- oracle sql rank dense_rank row_number fisrt last
測試表emp
- js判断当前的访问是手机还是电脑
<script type="text/javascript"> //平台.设备和操作系统 var system ={ win : false, mac : false, ...
- IIS常见错误
1.IIS7运行时访问报错,先安装VS,再启用的IIS,那么需要为IIS进行注册,在VS工具命令行中执行“aspnet_regiis.exe -ir -enable”即可 2.错误“未能加载文件或程序 ...
- hdu 3032 sg打表找规律 *
有n堆石子,alice先取,每次可以选择拿走一堆石子中的1~x(该堆石子总数) ,也可以选择将这堆石子分成任意的两堆.alice与bob轮流取,取走最后一个石子的人胜利. 打表代码: #include ...
- [Eclipse][SVN] 在eclipse上安装SVN
以前装过好多次SVN,始终没有一次把安装过程记录下来,这次新装机器,安装SVN插件时一波三折,记录下来免得以后又忘记了. 方法一: 1. 直接通过后台添加URL通过互联网进行安装,直接上图: 2. ...
- UML 类关系及画法
1 泛化 [泛化关系]:是一种继承关系,表示一般与特殊的关系,它指定了子类如何特化父类的所有特征和行为.例如:老虎是动物的一种,即有老虎的特性也有动物的共性. [箭头指向]:带三角箭头的实线,箭头指向 ...