[AHOI2009]飛行棋 BZOJ1800

題目描述

給出圓周上的若干個點,已知點與點之間的弧長,其值均為正整數,并依圓周順序排列。 請找出這些點中有沒有可以圍成矩形的,并希望在最短時間內找出所有不重復矩形。

輸入輸出格式

輸入格式:

第一行為正整數N,表示點的個數,接下來N行分別為這N個點所分割的各個圓弧長度

輸出格式:

所構成不重復矩形的個數

輸入輸出樣例

輸入樣例#1: 復制
8
1
2
2
3
1
1
3
3
輸出樣例#1: 復制
3

說明

N<=20

?

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-3
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {ll x = 0;char c = getchar();bool f = false;while (!isdigit(c)) {if (c == '-') f = true;c = getchar();}while (isdigit(c)) {x = (x << 1) + (x << 3) + (c ^ 48);c = getchar();}return f ? -x : x;
}ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {if (!b) {x = 1; y = 0; return a;}ans = exgcd(b, a%b, x, y);ll t = x; x = y; y = t - a / b * y;return ans;
}
*/int n;
int a[maxn];
int sum[maxn];int main() {//ios::sync_with_stdio(0);rdint(n);for (int i = 1; i <= n; i++)rdint(a[i]), sum[i] = sum[i - 1] + a[i];int ans = 0;for (int i = 1; i <= n; i++) {for (int j = i + 1; j <= n; j++) {if (sum[j] - sum[i] == (sum[n] / 2))ans++;}}cout << ans * (ans - 1) / 2 << endl;return 0;
}

?

轉載于:https://www.cnblogs.com/zxyqzy/p/10265361.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/280663.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/280663.shtml
英文地址,請注明出處:http://en.pswp.cn/news/280663.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

webapi+Quartz.NET解決若干定時程序同時運行的問題

項目現狀&#xff1a; 有若干定時程序需要自啟動運行&#xff0c;為了簡便程序部署等問題&#xff0c;采取這種辦法把定時程序集中管理到webapi中跟隨api發布 代碼架構介紹&#xff1a; 新建一個類庫&#xff0c;類庫引用Quartz&#xff08;Quartz.2.3.2&#xff09;&#xff0…

mac恢復iphone_免費下載:舊Mac和iPhone壁紙的令人震驚的完整檔案

mac恢復iphoneLove or hate Apple, you’ve got to admit: their background images are consistently stunning. Now you can download all of them. 愛或恨蘋果&#xff0c;您必須承認&#xff1a;它們的背景圖像始終令人贊嘆。 現在&#xff0c;您可以下載所有這些文件。 A …

Django01-1: request 方法

#POST request.method #返回全大寫字符穿&#xff0c;<class str> POST/GETrequest.POST #用戶提交數據&#xff0c;不包含文件 #<QueryDict>request.POST.get(hobby) #拿列表最后一個 request.POST.getList(hobby) #拿多個&#xff0c;列表全部#GET 獲取url &a…

Magicodes.IE 2.7.1發布

2.7.12022.12.01Magicodes.IE.EPPlus默認添加SkiaSharp.NativeAssets.Linux.NoDependencies包&#xff0c;以便于在Linux環境下使用導入驗證支持將錯誤數據通過Stream的方式返回&#xff0c;感謝sampsonye &#xff08;見pr#466&#xff09;2.7.02022.11.07添加SkiaSharp移除Si…

Oracle監聽的靜態注冊和動態注冊

靜態注冊&#xff1a;通過解析listene.ora文件 動態注冊&#xff1a;由PMON進程動態注冊至監聽中 在沒有listener.ora配置文件的情況下&#xff0c;如果啟動監聽&#xff0c;則監聽為動態注冊。用圖形化netca創建的監聽&#xff0c;默認也為動態注冊 1.靜態注冊 listener.ora文…

AKOJ-1695-找素數

題意&#xff1a; 給定區間L&#xff0c;R。 計算區間中素數個數。 2 < L,R < 2147483647, R-L < 1000000。 思路&#xff1a; 素數區間篩 先篩(2-sqrt(r))。 再用(2-sqrt(r))中的素數篩(l-r)。 代碼: 1.自己寫的區間篩&#xff0c;將篩2-sqrt&#xff08;r) 分開了。…

Spring 環境與profile(一)——超簡用例

什么是profile,為什么需要profile? 在開發時&#xff0c;不同環境&#xff08;開發、聯調、預發、正式等&#xff09;所需的配置不同導致&#xff0c;如果每改變一個環境就更改配置不但麻煩&#xff08;修改代碼、重新構建&#xff09;而且容易出錯。Spring提供了解決方案。 方…

Django04-1: ORM增刪改查

ORM 增刪改查 一、字段增加 #終端輸入 1.model里添加字段&#xff0c; 2.執行遷移命令。 3.終端里輸入默認值&#xff0c;繼續執行遷移命令。 #允許為空 再nulltrue&#xff0c;終端不需要輸入默認值 #設置默認值 defalult‘xxxx‘ 二、字段修改 1.直接修改代碼&…

Comcast以純文本泄露客戶Wi-Fi登錄信息,立即更改密碼

A Comcast Xfinity website was leaking Wi-Fi names and passwords, meaning now is a good time to change your Wi-Fi passcode. Comcast Xfinity網站泄漏了Wi-Fi名稱和密碼&#xff0c;這意味著現在是更改Wi-Fi密碼的好時機。 The site, intended to help new customers se…

SpringBoot詳解(一)-快速入門

SpringBoot詳解系列文章&#xff1a;SpringBoot詳解&#xff08;一&#xff09;-快速入門SpringBoot詳解&#xff08;二&#xff09;-Spring Boot的核心SpringBoot詳解&#xff08;三&#xff09;-Spring Boot的web開發SpringBoot詳解&#xff08;四&#xff09;-優雅地處理日志…

龍芯上跑WTM,為國產化做點貢獻

點擊上方藍字關注我哦“信創”&#xff0c;是一項國家戰略&#xff0c;即信息技術應用創新產業&#xff0c;它是數據安全、網絡安全的基礎&#xff0c;也是新基建的重要組成部分。信創從名稱上來看本意指向創新&#xff0c;但是自從漂亮國親手撕碎了“科技沒有國界”的謊言之后…

Class與Style綁定

對于數據綁定&#xff0c;一個常見的需求是操作元素的class列表和它的內聯樣式。因為它們都是attribute&#xff0c;我們可以用v-bind處理它們&#xff1a;只需要計算出表達式最終的字符串。不過&#xff0c;字符串拼接麻煩又易錯。因此&#xff0c;在v-bind用于class和style時…

PHP安裝之configure的配置參數

1、生成環境安裝配置如下 要求安裝如下庫&#xff1a; imagickgdmysqlmysqlimysqlndphalconPharsoapsocketsxwebxsvczipzlib 具體查看 vim php-config 就可以知道是如何配置的 --prefix/home/php --with-config-file-path/home/php/etc --with-mysql --with-pdo-oci --with-ope…

Django05: 請求生命周期流程圖/路由層

請求生命周期流程圖 擴展知識&#xff1a; 緩存數據庫 路由層 路由匹配 url(r^test/, views.test), 1. 第一個參數是正則匹配。 只要第一個匹配了&#xff0c;就不會執行下面。 輸入url會默認加斜杠&#xff0c;django會重定向 a. 一次匹配不行 b. url再加斜杠匹配 可以…

facebook 分享頁面_Facebook個人資料,頁面和組之間有什么區別?

facebook 分享頁面Facebook is used by a lot of different people for a lot of different things, so it’s only natural that Facebook would have different sets of features for each of them. There are three main ways you can use Facebook: with a regular Profile…

zabbix運行腳本監控ggsci報錯

/u01/app/oracle/oracle/ogg/ggsci: error while loading shared libraries: libdb-6.1.so: cannot open shared object file: No such file or directory增加腳本環境變量設置PATH$PATH:$HOME/binexport ORACLE_BASE/u01/app/oracleexport ORACLE_HOME$ORACLE_BASE/11/db_1exp…

一句話設計原則

面向對象的可復用設計&#xff08; Object Oriented Design / OOD&#xff09; 1. 開閉原則 (Open Closed Principle) 對擴展開放&#xff0c;對修改關閉 2. 里氏代換原則(LSP) 1.可以使用基類的地方&#xff0c;其子類必然也能使用 2.并且原功能不會受到任何影響 -- 經典案例,…

postman--安裝及Interceptor插件

1. 官網安裝&#xff08;看網速-我下載的時候一直下載失敗&#xff09;打開官網&#xff0c;https://www.getpostman.com選擇ios或者win 2. 非官網安裝 https://pan.baidu.com/s/1mstsimqO3ZC5m9z8czxVnA 密碼&#xff1a;q6yp 安裝postman 3.需要安裝分享的藍燈安裝包&#xf…

亞馬遜標題自動抓取_如何為您的家人提供自動Amazon禮品卡津貼

亞馬遜標題自動抓取When your kids move away to go to school, they’ll probably phone home every once in a while to ask for money. If they shop a lot on Amazon (and they probably do), you can expedite that process by setting up an automatically recurring dep…

Django04-2: ORM關系表\字段補充

一、表與表關系 一對多 多對多 一對一 圖書表 出版社 作者表 作者詳情表 出版社 和 圖書表 關系 一對多 外鍵字段在多的一方 book 圖書表 和 作者表 關系 多對多 需要創建第三張表 作者表 和 作者詳情表 關系 一對一 #創建表關系 先將基表創建 再添加外鍵字段 一對多…