周賽題解

A -?An easy problem
Time Limit:3000MS?????Memory Limit:32768KB?????64bit IO Format:%I64d & %I64u
Submit?Status?Practice?HDU 2601

Description

When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’s 1 cup of water plus 1 pile of dough ..” , “100 yuan buy 100 pig” .etc..?

One day Teddy met a old man in his dream , in that dream the man whose name was“RuLai” gave Teddy a problem :?

Given an N , can you calculate how many ways to write N as i * j + i + j (0 < i <= j) ??

Teddy found the answer when N was less than 10…but if N get bigger , he found it was too difficult for him to solve.?
Well , you clever ACMers ,could you help little Teddy to solve this problem and let him have a good dream ??

Input

The first line contain a T(T <= 2000) . followed by T lines ,each line contain an integer N (0<=N <= 10?10).

Output

For each case, output the number of ways in one line.

Sample Input

2 1 3

Sample Output

0 1
代碼;
 1 #include<stdio.h>
 2 #include<math.h>
 3 const int MAXN=100010;
 4 int main(){
 5     __int64 N,ans;
 6     int T;
 7     scanf("%d",&T);
 8     while(T--){
 9         ans=0;
10         scanf("%I64d",&N);
11         N++;
12         int flot=0;
13         for(int i=2;i<=sqrt(N);i++)if(N%i==0)ans++;
14         printf("%I64d\n",ans);
15     }
16     return 0;
17 }
C -?最少攔截系統
Time Limit:1000MS?????Memory Limit:32768KB?????64bit IO Format:%I64d & %I64u
Submit?Status?Practice?HDU 1257

Description

某國為了防御敵國的導彈襲擊,發展出一種導彈攔截系統.但是這種導彈攔截系統有一個缺陷:雖然它的第一發炮彈能夠到達任意的高度,但是以后每一發炮彈都不能超過前一發的高度.某天,雷達捕捉到敵國的導彈來襲.由于該系統還在試用階段,所以只有一套系統,因此有可能不能攔截所有的導彈.?
怎么辦呢?多搞幾套系統唄!你說說倒蠻容易,成本呢?成本是個大問題啊.所以俺就到這里來求救了,請幫助計算一下最少需要多少套攔截系統.?

Input

輸入若干組數據.每組數據包括:導彈總個數(正整數),導彈依此飛來的高度(雷達給出的高度數據是不大于30000的正整數,用空格分隔)?

Output

對應每組數據輸出攔截所有導彈最少要配備多少套這種導彈攔截系統.?

Sample Input

8 389 207 155 300 299 170 158 65

Sample Output

2
代碼:
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<vector>
 4 #include<algorithm>
 5 using namespace std;
 6 const int MAXN=30010;
 7 vector<int>vec;
 8 int main(){
 9     int N,x;
10     while(~scanf("%d",&N)){
11         int top=0;
12         vec.clear();
13         for(int i=0;i<N;i++){
14             scanf("%d",&x);
15         if(lower_bound(vec.begin(),vec.end(),x)==vec.end())vec.push_back(x);
16         else *lower_bound(vec.begin(),vec.end(),x)=x;
17         }
18         printf("%d\n",vec.size());
19     }
20     return 0;
21 }
G -?Ignatius and the Princess III
Time Limit:1000MS?????Memory Limit:32768KB?????64bit IO Format:%I64d & %I64u
Submit?Status?Practice?HDU 1028

Description

"Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.?

"The second problem is, given an positive integer N, we define an equation like this:?
??N=a[1]+a[2]+a[3]+...+a[m];?
??a[i]>0,1<=m<=N;?
My question is how many different equations you can find for a given N.?
For example, assume N is 4, we can find:?
??4 = 4;?
??4 = 3 + 1;?
??4 = 2 + 2;?
??4 = 2 + 1 + 1;?
??4 = 1 + 1 + 1 + 1;?
so the result is 5 when N is 4. Note that "4 = 3 + 1" and "4 = 1 + 3" is the same in this problem. Now, you do it!"?

Input

The input contains several test cases. Each test case contains a positive integer N(1<=N<=120) which is mentioned above. The input is terminated by the end of file.?

Output

For each test case, you have to output a line contains an integer P which indicate the different equations you have found.?

Sample Input

4 10 20

Sample Output

5 42 627
代碼:
 1 #include<stdio.h>
 2 #include<string.h>
 3 int main(){
 4     int N,a[150],b[150];
 5     while(~scanf("%d",&N)){
 6         for(int i=0;i<=N;i++)a[i]=1,b[i]=0;
 7         for(int i=2;i<=N;i++){
 8             for(int j=0;j<=N;j++){
 9                  b[j]+=a[j];
10                 for(int k=i;j+k<=N;k+=i){
11                     b[j+k]+=a[j];
12                 }
13             }
14             for(int j=0;j<=N;j++)
15                 a[j]=b[j],b[j]=0;
16         }
17         printf("%d\n",a[N]);
18     }
19     return 0;
20 }
H -?Charm Bracelet
Time Limit:1000MS?????Memory Limit:65536KB?????64bit IO Format:%I64d & %I64u
Submit?Status?Practice?POJ 3624

Description

Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the?N?(1 ≤?N?≤ 3,402) available charms. Each charm?i?in the supplied list has a weight?Wi?(1 ≤?Wi?≤ 400), a 'desirability' factor?Di?(1 ≤?Di?≤ 100), and can be used at most once. Bessie can only support a charm bracelet whose weight is no more than?M?(1 ≤?M?≤ 12,880).

Given that weight limit as a constraint and a list of the charms with their weights and desirability rating, deduce the maximum possible sum of ratings.

Input

* Line 1: Two space-separated integers:?N?and?M
* Lines 2..N+1: Line?i+1 describes charm?i?with two space-separated integers:?Wi?and?Di

Output

* Line 1: A single integer that is the greatest sum of charm desirabilities that can be achieved given the weight constraints

Sample Input

4 6
1 4
2 6
3 12
2 7

Sample Output

23
代碼:
 1 #include<stdio.h>
 2 #include<string.h>
 3 const int MAXN=200000;
 4 int bag[MAXN];
 5 #define MAX(x,y)(x>y?x:y)
 6 struct Node{
 7     int w,v;
 8 };
 9 Node dt[5000];
10 int main(){
11     int N,M;
12     while(~scanf("%d%d",&N,&M)){
13         memset(bag,0,sizeof(bag));
14         for(int i=0;i<N;i++)scanf("%d%d",&dt[i].w,&dt[i].v);
15         for(int i=0;i<N;i++){
16             for(int j=M;j>=dt[i].w;j--){
17                 bag[j]=MAX(bag[j],bag[j-dt[i].w]+dt[i].v);
18             }
19         }
20         printf("%d\n",bag[M]);
21     }
22     return 0;
23 }

?

轉載于:https://www.cnblogs.com/handsomecui/p/4841362.html

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

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

相關文章

matlab常用函數——數學函數

六、基本數學函數 1)基本運算符 +:加法運算符 -:減法運算符 *:矩陣乘法 .*:數組乘法 /:斜杠或者矩陣右除 B/A等于公式B*inv(A) ./:數組右除 A./B等于A(i,j)/B(i,j) \:反斜杠或者矩陣左除 A\B等于inv(A)*B .\:數組左除 A.\B等于B(i,j)/A(i,j) ^…

內存容量出現異常的解決辦法

【鄙視360人工服務工程師 笨死你!】 如果哪天的內存容量突然出現了異常 而且發現只有一半可以使用的時候 不是內存出現了問題 而是設置的問題。 【win 7 win 8 win 10通用的解決辦法】 問題描述&#xff1a; 我是win 10 64位系統 內存容量突然只有一半了 打開我的電腦的設置看了…

Oracle 變量綁定與變量窺視合集系列一

《Oracle 變量綁定與變量窺視合集》 數據庫環境 LEO1LEO1> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL R…

(原創)對某國的一次滲透

文章均由自己原創&#xff0c;只是一直沒有在自己博客發表。本地附件也沒有了&#xff0c;我是從網上找來我的以前的投稿。 寫在之前的廢話&#xff1a;小菜技術能力不行&#xff0c;如果你覺得此文實在看不下去&#xff0c;還請PASS掉。如果你對我的文章有興趣&#xff0c;可以…

matlab常用函數——方程函數

八、插值函數、線性方程解函數和多項式函數 1)插值函數 interp1q :1維快速線性插值法 yi=interp1q(x,Y,xi) interp1q正常執行條件: (1)x單調遞增列向量 (2)Y為列向量or行數為length(x)(3)xi為列向量,如果xi值在x的坐標范圍外,返回NaN 實例: x=(-5:0.5:5); y=sin…

C/C++ | 字節對齊

目的&#xff1a;優化CPU訪問數據效率 類型轉換&#xff1a;未對齊時&#xff0c;嚴格一些的系統會報段錯誤&#xff0c;未報錯的話效率也會有所下降。 各種結構的對齊&#xff1a; 編譯器的區別&#xff1a; 其實字節對齊的細節和具體編譯器實現相關&#xff0c;但一般而言&am…

關于python測試webservice接口的視頻分享

現在大公司非常流行用python做產品的測試框架&#xff0c;還有對于一些快速原型產品的開發也好&#xff0c;很好地支持OO編程&#xff0c;代碼易讀。 Python的更新挺快的&#xff0c;尤其是第三方庫。 對于測試人員&#xff0c;代碼基礎薄弱&#xff0c;用python語言容易上手。…

matlab常用函數——文件操作函數

十一、基本文件操作函數 1)文件創建函數 filemaker :把文件名與文件中函數名分開 。 filesep :文件目錄分隔。 fileparts :把目標文件名拆分成字符串形式輸出 。 tempdir :返回系統暫存地址名 。 tempname :返回系統暫存文件名 。 fullfile :創建文件名 2)文件打…

Struts2中文件上傳下載實例

1.單文件上傳 1 jsp頁面&#xff1a;2 3 <!-- 單文件上傳 -->4 <form action"Fileupload.action" method"post"5 enctype"multipart/form-data">6 username:7 <input type"tex…

最優化課堂筆記06-無約束多維非線性規劃方法(續)

6.5共軛方向法 6.5.1 共軛方向 6.5.1 共軛梯度法 6.6單純形法(不考) 6.7最小二乘法 6.7.2 改進的高斯-牛頓最小二乘法

opengl微發展理解

1.什么是OpenGL? 一種程序&#xff0c;可以與界面和圖形硬件交互作用、一個開放的標準 2.軟件管道 請看上圖 - Apllication層 表示你的程序&#xff08;調用渲染命令。如opengl API&#xff09; -Abstraction層 表示畫圖接口&#xff08;如OpenGL API或者DirectX API&a…

MacosX 下GCC編譯指定版本的代碼

export MACOSX_DEPLOYMENT_TARGET10.6轉載于:https://www.cnblogs.com/lovelylife/p/5754226.html

最優化作業第六章——共軛梯度法和鮑爾法

共軛梯度法&#xff1a; 代碼&#xff1a; #導入模塊 from sympy import * import sympy as sp #將導入的模塊重新定義一個名字以便后續的程序進行使用 from numpy import * import numpy as npdef main():#本例是利用共軛梯度法進行最優化x1,x2,alpha symbols("x1,x2,…

酒鬼隨機漫步(一個矢量類)

摘要: 閱讀全文這是一個定義的一個矢量類&#xff0c; 然后用矢量類模擬一個酒鬼的隨機漫步 問題很簡單&#xff0c; 實現也不麻煩&#xff0c; 但是這個小程序卻可以呈現出許多語法知識。而且代碼風格也不錯&#xff0c;因此保存在了這篇博客中。 建議&#xff1a; 1. 類的聲…

對高并發流量控制的一點思考

前言 在實際項目中&#xff0c;曾經遭遇過線上5WQPS的峰值&#xff0c;也在壓測狀態下經歷過10WQPS的大流量請求&#xff0c;本篇博客的話題主要就是自己對高并發流量控制的一點思考。 應對大流量的一些思路 首先&#xff0c;我們來說一下什么是大流量&#xff1f; 大流量&…

ndk學習19: 使用Eclipse調試so

1. 設置調試選項在AndroidManifest文件加入允許調試android:debuggable"true" 此時編譯項目會多出:2. 配置調試代碼把需要調試的代碼,放如按鈕事件中,如果放在OnCreate會導致連接調試器時,代碼已經跑完了Button btnTest (Button)findViewById(R.id.button1);btnT…

Inside the C++ Object Model | Outline

《Inside the C Object Model&#xff08;C對象模型&#xff09;》&#xff0c;這是一本灰常不錯的書&#xff01; CSDN下載頁面&#xff08;中文&#xff0c;侯捷譯&#xff09; 豆瓣評論 讀書筆記目錄如下&#xff08;不定時更新&#xff09;&#xff1a; 轉載于:https://www…

最優化課程筆記07——約束問題的非線性規劃方法(重點:拉格朗日乘子法和懲罰函數法)

7.1 間接法&#xff1a;約束轉化為無約束問題&#xff08;含一個重點&#xff1a;拉格朗日乘子法&#xff09; 當維數多的時候不適用 7.1.2拉格朗日乘子法&#xff08;重點&#xff09; 7.1.2.1 等式約束問題 7.1.2.2 不等式約束問題 7.1.3 懲罰函數法&#xff08;內懲罰函數法…

工業相機:傳感器尺寸與像元尺寸的關系

相同分辨率的工業相機&#xff0c;傳感器面積越大&#xff0c;則其單位像素的面積也越大&#xff0c;成像質量也會越好。同樣的500萬像素的工業相機&#xff0c;2/3”的傳感器成像質量就要優于1/2”的。一般來說&#xff0c;工業相機的靶面大小&#xff0c;如果要求不是太嚴格&…

macOS下安裝ipython

macOS下sudo安裝ipython&#xff0c;會提示限錯誤&#xff1a; [Errno 1] Operation not permitted: /tmp/pip-Elrhse-uninstall/System/Library... 解決方法&#xff1a; pip install ipython --user -U 參考&#xff1a; http://chaishiwei.com/blog/994.html 本文轉自 h2app…