[POJ 2356] Find a multiple
| Time Limit: 1000MS | Memory Limit: 65536K | |||
| Total Submissions: 6535 | Accepted: 2849 | Special Judge | ||
Description
Input
Output
If there are more than one set of numbers with required properties you should print to the output only one (preferably your favorite) of them.
Sample Input
5
1
2
3
4
1
Sample Output
2
2
3
Source
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 10010 struct Node
{
int x,y,s; //下标,余数,前缀和
bool operator <(const Node &t)const
{
if(y!=t.y) return y<t.y;
return x<t.x;
}
}p[N]; int main()
{
int n;
int flag;
int a[N];
while(scanf("%d",&n)!=EOF)
{
flag=;
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
p[i].s=p[i-].s+a[i];
p[i].x=i;
p[i].y=p[i].s%n;
if(!flag && p[i].y==)
{
flag=;
printf("%d\n",i);
for(int j=;j<=i;j++) printf("%d\n",a[j]);
}
}
if(flag) continue;
sort(p+,p+n+);
for(int i=;i<=n;i++)
{
if(p[i].y==p[i-].y)
{
int &l=p[i-].x;
int &r=p[i].x;
printf("%d\n",r-l);
for(int j=l+;j<=r;j++) printf("%d\n",a[j]);
break;
}
}
}
return ;
}
[POJ 2356] Find a multiple的更多相关文章
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
		
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
 - POJ 2356  Find a multiple 抽屉原理
		
从POJ 2356来体会抽屉原理的妙用= =! 题意: 给你一个n,然后给你n个数,让你输出一个数或者多个数,让这些数的和能够组成n: 先输出一个数,代表有多少个数的和,然后再输出这些数: 题解: 首 ...
 - poj 2356 Find a multiple(鸽巢原理)
		
Description The input contains N natural (i.e. positive integer) numbers ( N <= ). Each of that n ...
 - poj 2356 Find a multiple【鸽巢原理 模板应用】
		
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6651 Accepted: 2910 ...
 - POJ 2356 Find a multiple( 鸽巢定理简单题 )
		
链接:传送门 题意:题意与3370类似 注意:注意输出就ok,输出的是集合的值不是集合下标 /***************************************************** ...
 - 广搜+打表 POJ 1426   Find The Multiple
		
POJ 1426 Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25734 Ac ...
 - POJ 1426 Find The Multiple --- BFS || DFS
		
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...
 - POJ 1426 Find The Multiple(寻找倍数)
		
POJ 1426 Find The Multiple(寻找倍数) Time Limit: 1000MS Memory Limit: 65536K Description - 题目描述 Given ...
 - POJ.1426 Find The Multiple (BFS)
		
POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...
 
随机推荐
- Custom Control
			
How to create custom control http://www.silverlightshow.net/items/Creating-a-Silverlight-Custom-Cont ...
 - JS 原型链图形详解
			
JS原型链 这篇文章是「深入ECMA-262-3」系列的一个概览和摘要.每个部分都包含了对应章节的链接,所以你可以阅读它们以便对其有更深的理解. 对象 ECMAScript做为一个高度抽象的面向对象语 ...
 - WP-PostViews Plus停止计数
			
最近老是发现WP-PostViews Plus停止计数,网上查了资料才发现,WP Super Cache和WP-PostViews Plus存在冲突.根据自己网站目前的情况看,暂时用不到WP Supe ...
 - 大学生IT博客大赛最技术50强与最生活10强文章
			
姓名 学校 文章标题 文章地址 刘成伟 井冈山大学 [mystery]-linux黑客之网络嗅探底层原理 http://infohacker.blog.51cto.com/6751239/115511 ...
 - shell 后台执行命令
			
shell 后台执行命令方法: 1. nohup cmd & 后台会生成 nohup.out 文件 2.cmd >/路径/xx.log & 后台生成 xx. ...
 - js的基本概念详解
			
来自<javascript高级程序设计 第三版:作者Nicholas C. Zakas>的学习笔记(三) 如果你刚学js,想快速了解到js的基本概念,以下将会是一篇不错的引导文章: 语法 ...
 - 团体程序设计天梯赛-练习集L2-011. 玩转二叉树
			
L2-011. 玩转二叉树 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一棵二叉树的中序遍历和前序遍历,请你先将树做个镜 ...
 - 用IDEA调试Play工程
			
IDEA的版本是14.0.1,运行在MAC OS X Yosemite上. IDEA已经装了Scala插件,但是在新建工程中,Scala的选项中并没有Play框架,不知道什么原因. 导入Play工程 ...
 - hbase总结:如何监控region的性能
			
转载:http://ju.outofmemory.cn/entry/50064 随着大数据表格应用的驱动,我们的HBase集群越来越大,然而由于机器.网络以及HBase内部的一些不确定性的bug,使得 ...
 - iOS开发UI篇—程序启动原理和UIApplication1
			
iOS开发UI篇—程序启动原理和UIApplication 一.UIApplication 1.简单介绍 (1)UIApplication对象是应用程序的象征,一个UIApplication对象就 ...