守恒法的问题,表示,刚刚看了一点点

#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) 收藏的更多相关文章

  1. c++ 字符串流 sstream(常用于格式转换) 分类: C/C++ 2014-11-08 17:20 150人阅读 评论(0) 收藏

    使用stringstream对象简化类型转换 C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中 ...

  2. C/C++中const的用法 分类: C/C++ 2015-07-05 00:43 85人阅读 评论(0) 收藏

    const是C语言的关键字,经C++进行扩充,变得功能强大,用法复杂.const用于定义一个常变量(只读变量),当const与指针,引用,函数等结合起来使用时,情况会变得复杂的多.下面将从五个方面总结 ...

  3. 浅谈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 ...

  4. Least Common Ancestors 分类: ACM TYPE 2014-10-19 11:24 84人阅读 评论(0) 收藏

    #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #i ...

  5. short-path problem (Spfa) 分类: ACM TYPE 2014-09-02 00:30 103人阅读 评论(0) 收藏

    #include <cstdio> #include <iostream> #include <cstring> #include <queue> #i ...

  6. 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 ...

  7. iOS动画特效 分类: ios技术 2015-05-15 16:29 311人阅读 评论(0) 收藏

    关于图层的几个坐标系. 对于ios来说,坐标系的(0,0)点在左上角,就是越往下,Y值越大.越往右,X值越大. 一个图层的frame,它是position,bounds,anchorPoint和tra ...

  8. 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() ...

  9. 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 ...

随机推荐

  1. wordpress Warning: Parameter 2 to qtranxf_postsFilter() expected to be a reference

    wordpress qtranslate-x Warning: Parameter 2 to qtranxf_postsFilter() expected to be a reference Para ...

  2. 解决 php artisan route:list 报错oauth-private.key文件不存在或不可读的

    进入项目根目录命令行执行 php artisan passport:install 然后执行php artisan route:list,会提示 Class App\Http\Controllers\ ...

  3. 关于a标签的href属性值的区别

    一.href="javacript:;"  这种用法不正确,这么用的话会出现浏览器访问“javascript:;”这个地址的现象: 二.href="javacript:v ...

  4. Java环境配置:MacOS

    主要是在mac os下进行java环境配置. 下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads- ...

  5. MTT学习小记

    这是个毒瘤题才有的毒瘤东西--奶一口NOI不考 拆系数FFT: 考虑做NTT时模数不是NTT模数(\(2^a*b+1\))怎么办? 很容易想到拆次数FFT. 比如说现在求\(a*b\),设\(m=\s ...

  6. NX二次开发-NXOPEN_DimensionCollection遍历图纸上的所有标注尺寸

    NX11+VS2013 #include <NXOpen/Drawings_DrawingSheet.hxx> #include <NXOpen/Drawings_DrawingSh ...

  7. NX二次开发-获得制图中对象的坐标点UF_DRF_ask_origin

    #include <uf.h> #include <uf_ui.h> #include <uf_drf.h> #include <uf_obj.h> # ...

  8. 使用Docker在服务器上部署Ubuntu,本地传文件到docker

    使用Docker在服务器上部署Ubuntu,本地传文件到docker 作者:王佳乐 目录 安装Docker 安装Docker 全部安装流程: 登录服务器 ssh username@ip 检查是否已经安 ...

  9. PAT_A1020#Tree Traversals

    Source: PAT A1020 Tree Traversals (25 分) Description: Suppose that all the keys in a binary tree are ...

  10. ajax 接收json数据的进一步了解

    var url = "../searchclasses"; $.ajax({ url: url, type: "post", dataType: "j ...