题目出处:http://codeforces.com/problemset/problem/895/A
题目大意:对于给出的一些角度的披萨分成两份,取最小角度差
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//Pizza Separation
int main(){
int n;
scanf("%d",&n);
int *a = (int*) malloc (n * sizeof(int));
int i;
for(i=;i<n;i++){
scanf("%d",&a[i]);
}
if(n==){
printf("360\n");
return ;
}
//前缀和
for(i=;i<n;i++){
a[i] += a[i-];
}
int part1,part2,ans=;
for(i=;i<n-;i++){
for(int j=i+;j<n;j++){
part1 = abs(a[i] - a[j]);
if(part1==){
printf("0\n");
return ;
}else{
part2 = -part1;
int t = abs(part1 - part2);
ans = ans<t ? ans:t;
}
}
}
printf("%d",ans);
return ;
}

本题是本人在codeforces第一个解决的问题,很有意义,全程暴力不解释

895A. Pizza Separation#分披萨问题(前缀和)的更多相关文章

  1. codeforces 895A Pizza Separation 枚举

    codeforces 895A Pizza Separation 题目大意: 分成两大部分,使得这两部分的差值最小(注意是圆形,首尾相连) 思路: 分割出来的部分是连续的,开二倍枚举. 注意不要看成0 ...

  2. Codeforces Round #448 (Div. 2) A. Pizza Separation【前缀和/枚举/将圆(披萨)分为连续的两块使其差最小】

    A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. CodeForces:#448 div2 a Pizza Separation

    传送门:http://codeforces.com/contest/895/problem/A A. Pizza Separation time limit per test1 second memo ...

  4. Codeforces 895.A Pizza Separation

    A. Pizza Separation time limit per test 1 second memory limit per test 256 megabytes input standard ...

  5. #448 div2 a Pizza Separation

    A. Pizza Separation time limit per test1 second memory limit per test256 megabytes inputstandard inp ...

  6. 牛客网 NOIP赛前集训营-普及组(第四场)C--部分和 (高维前缀和)

    传送门 解题思路 高维前缀和模板题.首先,求前缀和有两种方式,比如说对于求二维前缀和来说. 第一种 : for(int i=1;i<=n;i++) for(int j=1;j<=n;j++ ...

  7. poj3122--二分加贪心

    大致题意: 就是公平地分披萨pie 我生日,买了n个pie,找来f个朋友,那么总人数共f+1人 每个pie都是高为1的圆柱体,输入这n个pie的每一个尺寸(半径),如果要公平地把pie分给每一个人(就 ...

  8. 动态规划-不连续最大子序列和-打家劫舍系列-1388. 3n 块披萨

    2020-03-24 17:49:58 198. 打家劫舍 问题描述: 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你偷窃的唯一制约因素就是相邻的房屋装有相互连通的防盗系统, ...

  9. Codeforces Round #448(Div.2) Editorial ABC

    被B的0的情况从头卡到尾.导致没看C,心情炸裂又掉分了. A. Pizza Separation time limit per test 1 second memory limit per test ...

随机推荐

  1. Zookeeper--命令介绍

    参考 https://zookeeper.apache.org/doc/r3.4.13/zookeeperStarted.html#sc_ConnectingToZooKeeper 连接到zookee ...

  2. zabbix监控tcp/nginx/memcache连接数自定义监控shell

    #!/bin/bashtcp_status_fun(){ TCP_STAT=$1 #netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in st ...

  3. delphi的procedure of object

    delphi的procedure of object(一个特殊的指针类型) 理论: //适用于实现不是某一特定过程或函数 type TNotifyEvent = procedure(Sender: T ...

  4. 微信小程序之组件常见的问题

    小程序自定义的组件: (1)组件的结构 自定义的组件和普通的页面定义没有什么区别,也包含了四个文件:xxx.wxml(组件的视图层),xxx.json,xxx.js,xxx.wxss 组件的xxx.w ...

  5. 安装adobe reader阅读器

    首先  在我的网盘里有那个软件. 安装的教程在这个歌网址:http://www.zhanshaoyi.com/6730.html

  6. hdu2457(最少替换多少个字符使主串不包含模式串)ac自动机+dp

    题:http://acm.hdu.edu.cn/showproblem.php?pid=2457 题意:给定n个模式串,给定一个主串,问最替换掉多少个字符使主串不包含模式串或输出“-1”表示没有可行的 ...

  7. liburl常见库函数解释

    curl_slist_append - add a string to an slist(单链表) struct curl_slist *headerlist=NULL;static const ch ...

  8. JAVA中如何判断一个输入是数字(小数和整数)还是字符串?

    public class Test1 {     public static void main(String[] args) {         Scanner input = new Scanne ...

  9. UVA 10806 最小费用最大流

    终于可以写这道题的题解了,昨天下午纠结我一下下午,晚上才照着人家的题解敲出来,今天上午又干坐着想了两个小时,才弄明白这个问题. 题意很简单,给出一个无向图,要求从1 到 n最短路两次,但是两次不允许经 ...

  10. 01 语言基础+高级:1-8 File类与IO流_day08【 File类、递归】

    day08[File类.递归] 主要内容 File类 递归 教学目标 能够说出File对象的创建方式 能够说出File类获取名称的方法名称 能够说出File类获取绝对路径的方法名称 能够说出File类 ...