多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > 互聯(lián)網(wǎng) > HDU 5047 Sawtooth(數(shù)學(xué) 公式 大數(shù))

HDU 5047 Sawtooth(數(shù)學(xué) 公式 大數(shù))

來源:程序員人生   發(fā)布時(shí)間:2014-10-09 03:04:26 閱讀次數(shù):3221次

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5047


Problem Description
Think about a plane:

● One straight line can divide a plane into two regions.
● Two lines can divide a plane into at most four regions.
● Three lines can divide a plane into at most seven regions.
● And so on...

Now we have some figure constructed with two parallel rays in the same direction, joined by two straight segments. It looks like a character “M”. You are given N such “M”s. What is the maximum number of regions that these “M”s can divide a plane ?

 

Input
The first line of the input is T (1 ≤ T ≤ 100000), which stands for the number of test cases you need to solve.

Each case contains one single non-negative integer, indicating number of “M”s. (0 ≤ N ≤ 1012)
 

Output
For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then an integer that is the maximum number of regions N the “M” figures can divide.
 

Sample Input
2 1 2
 

Sample Output
Case #1: 2 Case #2: 19
 

Source
2014 ACM/ICPC Asia Regional Shanghai Online


PS:

推出公式:8*n^2 - 7*n + 1 ,套一下模板就好了! 不過很多大數(shù)模板這題是會(huì)T的,不過這個(gè)模板:http://blog.csdn.net/u012860063/article/details/39612037  多虧了隊(duì)友的神模板2333333!


代碼如下:

#include <cstdio> #include <cstring> #include <malloc.h> /*大數(shù)加法*/ void add(char* a,char* b,char* c) { int i,j,k,max,min,n,temp; char *s,*pmax,*pmin; max=strlen(a); min=strlen(b); if (max<min) { temp=max; max=min; min=temp; pmax=b; pmin=a; } else { pmax=a; pmin=b; } s=(char*)malloc(sizeof(char)*(max+1)); s[0]='0'; for (i=min-1,j=max-1,k=max; i>=0; i--,j--,k--) s[k]=pmin[i]-'0'+pmax[j]; for (; j>=0; j--,k--) s[k]=pmax[j]; for (i=max; i>=0; i--) if (s[i]>'9') { s[i]-=10; s[i-1]++; } if (s[0]=='0') { for (i=0; i<=max; i++) c[i-1]=s[i]; c[i-1]=' 主站蜘蛛池模板: 中文字幕日韩专区 | 国产在线喷潮免费观看 | 欧美一区二区激情三区 | 欧美日韩国产不卡在线观看 | 日本护士xxx | 日韩欧美一级a毛片欧美一级 | 无码中文av有码中文av | 人操人操 | 动漫精品欧美一区二区三区 | 亚洲春色第一页 | 成人国产一区二区三区精品 | 亚洲在线视频播放 | 国产精品成人不卡在线观看 | 欧美啪啪毛片一区二区 | 欧美黑人巨大xxxx猛交 | 亚洲欧美韩国日本 | 天堂在线观看视频 | 日本韩国欧美在线观看 | 成人亚洲综合 | 亚洲精品视频在线 | 天堂免费观看 | 开心丁香婷婷深爱五月 | 日韩精品一区二区三区中文 | a毛片在线播放 | 伊人久久中文大香线蕉综合 | 国产精品久久久久久久久免费观看 | 美女网站免费看 | 亚洲天堂一区二区三区 | 亚州精品一区二区三区 | 在线成人亚洲 | 在线观看免费黄色网址 | 欧美成人网在线综合视频 | 在线观看亚洲网站 | 福利99| 亚洲网站在线免费观看 | 国产三级高清 | 亚洲欧美日韩在线精品一区二区 | 三级国产精品一区二区 | 成人性生活免费视频 | 一区二区三区四区日韩 | 成人香蕉xxxxxxx|