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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

toj 3616 Add number (没想到啊~~)

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 toj 3616 Add number (没想到啊~~) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Add number

時間限制(普通/Java):1000MS/3000MS 運行內存限制:65536KByte
總提交: 60 測試通過: 21

描述

?

Employees of Baidu like to play a game called Making Numbers. It goes like this: there are two players in the game, one is called little A, the other little B. There are some cards with a number on each one of them, little A chooses a number X from 1 to N randomly, while little B has to choose some cards, the sum of which equals X. Now there are already M cards with numbers, and K blank cards. At the beginning of the game, little B is allowed to write numbers on the blank cards. Now little B wants to know, if it is possible to write some numbers that will assure him of the victory, that is to say, if it is possible for him to make up any number from 1 to N with the cards.

?

輸入

?

The input consists of several test cases. The first line is an integer T,

The first line of each case shows 3 numbers, N M K, the next line follows M numbers that are already written on M cards. 1<=N<=99999999,0<=M<=19,1<=K<=19 and the numbers on M cards are above 0, smaller than or equals N, in non-descending order.

?

輸出

?

If little B can make it, output "YES", else output "NO".

?

樣例輸入

?

3 15 0 412 3 2 3 3 3 13 3 2 3 3 3

?

樣例輸出

?

YES YES NO

?

題目來源

第四屆北京郵電大學程序設計競賽 2010

?

1 #include <stdio.h> 2 int main() 3 { 4 int T; 5 scanf("%d", &T); 6 while(T--){ 7 int n, m, k; 8 scanf("%d %d %d", &n, &m, &k); 9 int a[100]; 10 for(int i = 0; i < m; i++){ 11 scanf("%d", a+i); 12 } 13 int sum = 0; 14 int tmp = 1; 15 while(sum < n && k >= 0){ 16 bool flag = false; 17 for(int i = 0; i < m; i++){ 18 if(a[i] && a[i] <= tmp){ 19 sum += a[i]; 20 a[i] = 0; 21 flag = true; 22 } 23 } 24 if(!flag){ 25 sum += tmp; 26 k--; 27 } 28 tmp = sum + 1; 29 } 30 if(k >= 0 && sum >= n){ 31 puts("YES"); 32 } 33 else{ 34 puts("NO"); 35 } 36 } 37 return 0; 38 }

?

轉載于:https://www.cnblogs.com/luotinghao/p/3411224.html

總結

以上是生活随笔為你收集整理的toj 3616 Add number (没想到啊~~)的全部內容,希望文章能夠幫你解決所遇到的問題。

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