日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

TOJ-3474 The Big Dance(递归二分)

發布時間:2024/1/18 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 TOJ-3474 The Big Dance(递归二分) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

?

鏈接:https://ac.nowcoder.com/acm/contest/1077/L

題目描述

Bessie and the herd, N (1 <= N <= 2,200) conveniently numbered 1..N cows in all, have gone to a dance where plenty of bulls are available as dancing partners. This dance is known as the "odd cow out" dance because of the way cows are chosen to dance with bulls.
The cows are lined up in numerical order and the 'middle' point is chosen. It either divides the line of cows exactly in half or it is chosen so that the first set of cows has just one more cow in it than the second set. If exactly two cows are in the set, they are chosen to dance with bulls. If one cow is in the set, she is sent home with a consolation prize of a beautiful rose.
If the set has more than two cows in it, the process is repeated perhaps again and again until sets with just one or two cows emerge.
The two cow ID numbers are multiplied together and added to a global sum.
Given the number of cows at the dance, compute the global sum after all the eligible cows are chosen. Consider a dance with 11 cows numbered 1..11. Here is the sequence of dividing them: 1 2 3 4 5 6 | 7 8 9 10 111 2 3 | 4 5 61 2 | 31 2 => 1*2=2 added to sum -> sum=23 => sent home with rose4 5 | 64 5 => 4*5=20 added to sum -> sum=226 => sent home with rose7 8 9 | 10 117 8 | 97 8 => 7*8=56 added to sum -> sum=789 => sent home with rose10 11 => 10*11=110 added to sum -> sum=188So the sum for this dance would be 188.

輸入描述:

* Line 1: A single integer: N

輸出描述:

* Line 1: A single integer that is the sum computed as prescribed.

示例1

輸入

11

輸出

188

?

簡單二分,直接粘代碼

1 #include <stdio.h> 2 #include <string.h> 3 #include <iostream> 4 #include <string> 5 #include <math.h> 6 #include <algorithm> 7 #include <vector> 8 #include <queue> 9 #include <set> 10 #include <map> 11 #include <math.h> 12 const int INF=0x3f3f3f3f; 13 typedef long long LL; 14 const int mod=1e9+7; 15 const double PI=acos(-1); 16 const int maxn=100010; 17 using namespace std; 18 //ios::sync_with_stdio(false); 19 // cin.tie(NULL); 20 21 int n,ans; 22 23 void solve(int l,int r) 24 { 25 if(l==r) 26 return ; 27 if(l+1==r) 28 { 29 ans+=l*r; 30 return ; 31 } 32 int mid=(l+r)>>1; 33 solve(l,mid); 34 solve(mid+1,r); 35 return ; 36 } 37 38 int main() 39 { 40 scanf("%d",&n); 41 solve(1,n); 42 printf("%d\n",ans); 43 return 0; 44 }

?

?

?

?

轉載于:https://www.cnblogs.com/jiamian/p/11382986.html

總結

以上是生活随笔為你收集整理的TOJ-3474 The Big Dance(递归二分)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美激情综合网 | 瑟瑟在线观看 | 美女裸片 | 人人看人人爽 | porn麻豆| 国产成人啪一区二区 | 色哟哟欧美精品 | 操夜夜操 | 动漫av在线| 91久久综合精品国产丝袜蜜芽 | 性欧美大战久久久久久久久 | 日本黄色小视频 | 性感美女一区二区三区 | 精品99久久久| av一级久久| 性视频久久| 国产一级黄 | 国产又粗又猛又爽又黄的视频一 | 国产毛片电影 | av鲁丝一区二区鲁丝 | 国语对白做受xxxxx在线中国 | 少妇喷白浆 | 亚洲夜色| 91在线成人 | 男人的天堂av女优 | 成年人三级网站 | 成人看 | xxxx在线视频 | 日韩成人区 | 国产欧美日韩亚洲 | 成人精品一区二区三区视频 | 久久久久99精品成人片毛片 | 小视频在线| 日韩久久中文字幕 | 8x8x永久免费视频 | 男人在线天堂 | 秋霞视频在线观看 | 成人久久久精品乱码一区二区三区 | 成年人黄色大全 | 亚洲成人一区 | 香蕉视频在线观看视频 | 久久久久一区二区精码av少妇 | av色站| 免费人成在线 | 中文字幕精品在线视频 | 星空大象在线观看免费播放 | 日本丰满熟妇bbxbbxhd | 草莓视频在线观看入口w | av午夜在线| 欧美高清精品一区二区 | 欧美性免费 | 亚洲无码高清精品 | 国产一区不卡在线观看 | 日韩激情av | 在线观看亚洲精品 | jizzjizz日本免费视频 | 91精品国产91久久久久久 | 91婷婷在线 | 精品麻豆视频 | 男人免费网站 | 狠狠操天天射 | 日韩免费专区 | 日韩高清免费观看 | 欧美日韩一区视频 | 91麻豆产精品久久久久久夏晴子 | 欧美三级一级片 | 午夜精品一区二区三区三上悠亚 | 国产人妻一区二区三区四区五区六 | 精品精品视频 | 丝袜一区二区三区四区 | 欧美国产精品一区二区 | 久久加勒比 | 久久久性色精品国产免费观看 | 欧美日韩一区二区三区四区 | 伦一理一级一a一片 | 久草在在线 | 伊人婷婷综合 | 看看黄色片 | 福利社午夜| 亚洲国产欧美在线 | 亚洲精品aⅴ中文字幕乱码 国产精品调教视频 | 色亚洲影院 | 国产一区二区视频在线免费观看 | 久草热在线 | 色爱av | 精久久久久 | 欧美双性人妖o0 | 亚洲制服av | 福利视频91 | 全部孕妇毛片丰满孕妇孕交 | 一区在线观看视频 | 日本国产在线视频 | 亚洲精品成人无码 | 色狠狠一区二区 | 色播综合| 精品一区中文字幕 | 强公把我次次高潮hd | 日批视频在线免费看 | 在线观看黄色片网站 |