水题来的……我的做法是用a[10]数组表示每个数字出现的次数。

1200. Stick

限制条件

时间限制: 1 秒, 内存限制: 32 兆

题目描述

Anthony has collected a large amount of sticks for manufacturing chopsticks. In order to simplify his job, he wants to fetch two equal-length sticks for machining at a time. After checking it over, Anthony finds that it is always possible that only one stick is left at last, because of the odd number of sticks and some other unknown reasons. For example, Anthony may have three sticks with length 1, 2, and 1 respectively. He fetches the first and the third for machining, and leaves the second one at last. You task is to report the length of the last stick.

输入格式

The input file will consist of several cases.

Each case will be presented by an integer n (1<=n<=100, and n is odd) at first. Following that, n positive integers will be given, one in a line. These numbers indicate the length of the sticks collected by Anthony.

The input is ended by n=0.

输出格式

For each case, output an integer in a line, which is the length of the last stick.

样例输入

3
1
2
1
0

样例输出

2

题目来源

ZSUACM Team Member

 #include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n,a[];
while(cin>>n && n){
for(int i=;i<n;i++) cin>>a[i];
for(int i=;i<n-;i++) if(a[i]){
for(int j=i+;j<n;j++)
if(a[i]==a[j]){
a[i]=;a[j]=;break;
}
continue;
}
for(int i=;i<n;i++) if(a[i]) cout<<a[i]<<endl;
}
return ;
}

sicily 1200欢迎提出优化方案的更多相关文章

  1. Sicily 1510欢迎提出优化方案

    这道题我觉得是除1000(A-B)外最简单的题了……不过还是提出一个小问题:在本机用gcc编译的时候我没包括string.h头文件,通过编译,为什么在sicily上却编译失败? 1510. Mispe ...

  2. Sicily 1068欢迎提出优化方案

    1608. Digit Counting 限制条件 时间限制: 1 秒, 内存限制: 32 兆 题目描述 Trung is bored with his mathematics homeworks. ...

  3. iOS界面跳转的一些优化方案

    原文地址: http://blog.startry.com/2016/02/14/Think-Of-UIViewController-Switch/ iOS界面跳转的一些优化方案 App应用程序开发, ...

  4. (转)Web性能优化方案

    第一章 打开网站慢现状分析 在公司访问部署在IDC机房的VIP网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...

  5. AngularJS应用页面切换优化方案

    葡萄城的一款尚在研发中的产品,对外名称暂定为X项目.其中使用了已经上市的Wijmo中SpreadJS产品,另外,在研发过程中整理了一些研发总结分享给大家.如本篇的在页面切换的过程中优化方案,欢迎大家跟 ...

  6. AngularJs应用页面切换优化方案(转)

    目录[-] 前言 场景 使用resolve来提前请求数据 为页面加入切换动画 总结 葡萄城的一款尚在研发中的产品,对外名称暂定为X项目.其中使用了已经上市的wijmo中SpreadJS产品,另外,在研 ...

  7. Adapter优化方案的探索

    概要:使用Adapter的注意事项与优化方案本文的例子都可以在结尾处的示例代码连接中看到并下载,如果喜欢请star,如果觉得有纰漏请提交issue,如果你有更好的点子可以提交pull request. ...

  8. Web性能优化方案

    第一章 打开网站慢现状分析 在公司访问部署在IDC机房的VIP网站时会感觉很慢.是什么原因造成的?为了缩短页面的响应时间,改进我们的用户体验,我们需要知道用户的时间花在等待什么东西上. 可以跟踪一下我 ...

  9. 大批量delete 优化方案

    超过100万以上数据 删除的时候 会非常慢且产生大量日志文件 最大的问题是内存爆表 导致得多次重启服务才能删除整个库 暂时提出初步优化方案 1.设置日志为简单模式,处理完后恢复 ALTER DATAB ...

随机推荐

  1. HBase 使用场景和成功案例

    有时候了解软件产品的最好方法是看看它是怎么用的.它可以解决什么问题和这些解决方案如何适用于大型应用架构,能够告诉你很多.因为HBase有许多公开的产品部署,我们正好可以这么做.本章节将详细介绍一些人们 ...

  2. Django中载入js和css文件

    Django中载入js和css文件 项目的文件夹结构例如以下: mysite |-mysite |-|-static |-|---js和css文件 |-|-|-init.py |-| |-models ...

  3. 0703-APP-Notification-statue-bar

    1.展示显示textTicker和仅仅有icon的两种情况:当參数showTicker为true时显示否则不显示 // In this sample, we'll use the same text ...

  4. PHP中的正则表达式函数preg_

    preg_match();     //用于正则表达式的匹配,且只匹配一次 preg_match_all();//用于正则表达式的匹配,会对所有符合规则的都进行匹配 preg_replace();   ...

  5. ios的NSMutableString用法

    版权声明:本文为博主原创文章,未经博主允许不得转载. 详见代码: // //  main.m //  Foundation5-NSMutableString // //  Created by mj  ...

  6. iOS开发——面试指导

    iOS面试指导 一 经过本人最近的面试和对面试资料的一些汇总,准备记录这些面试题,以便ios开发工程师找工作复习之用,本人希望有面试经验的同学能和我同时完成这个模块,先出面试题,然后会放出答案. 1. ...

  7. percona监控模板图形解释

    http://blog.itpub.net/28916011/viewspace-1971933/ percona监控mysql的几张图形解释     最近,我仔细研究了一下percona监控mysq ...

  8. 项目源码--Android高质量图片浏览器源码

      下载源码   技术要点: 1. 浏览所有格式的图片 2. 图片缓存到数据库 3. Sqlite数据库的高级应用 4. 文件夹缩图显示 5. 多点触控技术 6. 动画技术 7. 支持超高清图片 8. ...

  9. JAVA_Gson_example

    package cn.kjxy.GSON; import java.util.List; import cn.kjxy.JSON.HttpHelpers; import com.google.gson ...

  10. Azure CLI (一)如何安装和配置Azure CLI

    什么是Azure CLI 快速安装 Azure 命令行界面 (Azure CLI),以便使用一组基于 shell 的开源命令在 Azure 中创建和管理资源. 步骤 1:安装 . 登录https:// ...