NYOJ-109 数列转换 AC 分类: NYOJ 2014-12-01 00:54 84人阅读 评论(0) 收藏
守恒法的问题,表示,刚刚看了一点点
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int T, n;
bool flag;
int num[10005];
int ans[10005];
int sux[10005];
int sum[10005];
cin>>T;
while(T--)
{
memset(num, 0, sizeof(num));
memset(sum, 0, sizeof(sum));
memset(ans, 0, sizeof(ans));
memset(sux, 0, sizeof(sux));
flag = true;
cin>>n;
for(int i = 1; i <= n; i++)
{
cin>>num[i];
sum[i] = sum[i-1] + num[i];
}
for(int i = 1; i <= n; i++)
{
cin>>ans[i];
sux[i] = sux[i-1] + ans[i];
}
sort(sum+1, sum+1+n);
sort(sux+1, sux+1+n);
for(int i = 1; i <= n; i++)
if(sum[i]!=sux[i]) flag = false;
if(flag) printf("Yes\n");
else printf("No\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
NYOJ-109 数列转换 AC 分类: NYOJ 2014-12-01 00:54 84人阅读 评论(0) 收藏的更多相关文章
- c++ 字符串流 sstream(常用于格式转换) 分类: C/C++ 2014-11-08 17:20 150人阅读 评论(0) 收藏
使用stringstream对象简化类型转换 C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中 ...
- C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏
const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...
- 浅谈new operator、operator new和placement new 分类: C/C++ 2015-05-05 00:19 41人阅读 评论(0) 收藏
浅谈new operator.operator new和placement new C++中使用new来产生一个存在于heap(堆)上对象时,实际上是调用了operator new函数和placeme ...
- Least Common Ancestors 分类: ACM TYPE 2014-10-19 11:24 84人阅读 评论(0) 收藏
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...
- short-path problem (Spfa) 分类: ACM TYPE 2014-09-02 00:30 103人阅读 评论(0) 收藏
#include <cstdio> #include <iostream> #include <cstring> #include <queue> #i ...
- Monthly Expense(二分) 分类: 二分查找 2015-06-06 00:31 10人阅读 评论(0) 收藏
Description Farmer John is an astounding accounting wizard and has realized he might run out of mone ...
- iOS动画特效 分类: ios技术 2015-05-15 16:29 311人阅读 评论(0) 收藏
关于图层的几个坐标系. 对于ios来说,坐标系的(0,0)点在左上角,就是越往下,Y值越大.越往右,X值越大. 一个图层的frame,它是position,bounds,anchorPoint和tra ...
- NYOJ-36 最长公共子序列 AC 分类: NYOJ 2014-01-03 20:54 155人阅读 评论(0) 收藏
#include<stdio.h> #include<string.h> #define N 1010 #define max(x,y) x>y?x:y int dp() ...
- NYOJ-733 万圣节派对 AC 分类: NYOJ 2014-01-02 00:41 303人阅读 评论(0) 收藏
#include <stdio.h> #include <math.h> int main() { int t, a, b, i, j, n; scanf("%d&q ...
随机推荐
- IDEA中统计项目代码的总行数
方法 安装“Statistic”插件步骤 打开idea设置界面,选择 plugins标签 点击下面“Browse repositories”按扭,浏览插件仓库 搜索“Statist ...
- 暑假集训test-8-30
这套题有毒,T1标程挂了,T2题面完全莫名其妙,T3没有告诉取模害我打了好久高精... A题. 统计每个数后面比它小的数的个数记作f把,操作一个数就是把它后面所有比它小的数和它的f清0,然后若是它到它 ...
- iOS7 AVAudioRecorder不能录音
今天写录音代码的时候,在iOS7以下就可以录音,但是iOS7上不可以,后来才知道iOS7录音方式变了,加上下面的代码就可以了,bingo AVAudioSession *audioSession = ...
- Devstack — screen 调试工具的使用
目录 目录 为什么要使用 screen 工具 启动 screen screen 的切换常用 退出和重新连接 screen Restart Openstack Services screen 指令选项总 ...
- MDK KEIL 机构体初始化 . 点 成员 初始化, C99
C99介绍,参考这里:C89,C99: C数组&结构体&联合体快速初始化 MDK 设置: 只需添加 ”--c99"参数即可,如图:
- 2019 牛客多校第一场 E ABBA
题目链接:https://ac.nowcoder.com/acm/contest/881/E 题目大意 问有多少个由 (n + m) 个 ‘A’ 和 (n + m) 个 ‘B’,组成的字符串能被分割成 ...
- static 关键字的使用及说明
static 关键字主要有以下几种使用场景: 修饰类的成员变量. 修饰类的成员方法. 修饰类的代码块. 修饰内部类. 1. static 修饰类的成员变量时,被称为静态成员变量.引用 static 修 ...
- 剑指offer——06二叉树的下一个节点
题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回.注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针. 题目的意思是,在一颗二叉树的中序遍历中,给出其中一 ...
- map、filter、forEach、reduce数组方法的封装
1.map方法的封装 Array.prototype.mapAlley = function(callback){ //获取调用mapAlley这个方法的数组 let arr = thi ...
- subId、slotId、SubscriptionInfo和SubscriptionManager的解释及关系说明
1. subid和slotid(phoneid) slotid(phoneid)是指卡槽:双卡机器的卡槽1值为0,卡槽2值为1,依次类推. subid:SubscriptionId(Subscript ...