找最佳通路

73. 找最佳通路★☆   輸入檔案:city.in   輸出檔案:city.out   簡單對比時間限制:1 s   記憶體限制:128 MB問題描述有 n 個 城市,它們之間的交通情況已知。現在要求根據一個出發點Cs和一個到達點Cd,請編程式,由電腦找到從城市Cs 到 Cd 的一條路徑,要求經過城市最少。【輸入格式】輸入檔案:

codeforces 242E XOR on Segment

E. XOR on Segmenttime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got an array a, consisting of n integers a1, a2, ..., an. You are allowed to perform two operations on this array:Calculate

Mother’s Milk

Mother's MilkFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while bucket C is full of milk. Sometimes, FJ pours

UVA 11020

題目:http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=33058想清楚增加點p後,會產生的情況,一,這個點可能本身沒有優勢,因此直接忽略。二,這個點有優勢,則把他加入到集合中,把因這個點的加入而沒有優勢的點刪除。#include <cmath>#include <ctime>#include <iostream>#include <string>#include

UVA10014- Simple calculations

思路:剛開始依照題目所給的a[i]= (a[i - 1] + a[i + 1]) / 2 - c[i],列出1到i的式子,然後全部相加,化簡,得到a[1] = a[i + 1] - a[i] + a[0] - 2C(i);            之後就蒙了。。。不懂怎麼搞了,後來網上看來下才發現化簡的式子在進行累加的話,可以把a[i]化去,最後得到公式(i + 1)a[1] = a[i + 1] + n * a[0] - 2 *

Crafting Winning Solutions

 Crafting Winning SolutionsA good way to get a competitive edge is to write down a game plan for what you're going to do in a contest round. This will help you script out your actions, in terms of what to do both when things go right and when things

math.h中的函數

數學函數庫,一些數學計算的公式的具體實現是放在math.h裡,具體有:  1、 三角函數  double sin (double);正弦  double cos (double);餘弦  double tan (double);正切、反三角函數  double asin (double); 結果介於[-PI/2, PI/2]  double acos (double); 結果介於[0, PI]  double atan (double); 反正切(主值), 結果介於[-PI/2, PI/2]  

hdu 1179 |hdu 2063

題目:http://acm.hdu.edu.cn/showproblem.php?pid=1179裸題。。二分圖的最大匹配。、下面是1179 AC代碼:#include<cstdio>#include<cstring>using namespace std;const int maxn = 110;int n,m,k;int g[maxn][maxn];int match[maxn];bool vis[maxn];bool dfs(int cur){

單詞尋找樹

293. [NOI2000] 單詞尋找樹★   輸入檔案:trie.in   輸出檔案:trie.out   簡單對比時間限制:1 s   記憶體限制:128

跳馬問題

49. 跳馬問題★   輸入檔案:horse.in   輸出檔案:horse.out   簡單對比時間限制:1 s   記憶體限制:128 MB問題描述有一隻中國象棋中的 “ 馬 ” ,在半張棋盤的左上方出發,向右下角跳去。規定只許向右跳(可上,可下, 但不允許向左跳)。請編程求從起點 A(1,1) 到終點 B(m,n) 共有多少種不同跳法。【輸入格式】輸入檔案只有一行,兩個整數m和n,兩個數之間有一個空格。【輸出格式】輸出檔案只有一個資料,即從 A 到 B 全部的走法【輸入輸出範例】輸入檔案(

UVA10161Ant on a Chessboard

題意:找出所給數位座標思路:對角線上的數符合a = n * (n - 1) + 1,然後從奇偶行的數與對角線上的數的大小關係,推出座標 #include<stdio.h>#include<math.h>void found(int x){int m = ceil(sqrt(x));int num = m * (m - 1) + 1;if (m % 2 == 0){if(x < num)printf("%d %d\n", m - (num - x),

UVA11292-The Dragon of Loowater

題意:給出龍的頭數和頭的數值,勇士的人數和需要用的錢,求出國王話費最少的錢才能將龍殺死,也可能殺不死思路:先將兩個數組排序,然後進行比較就可以了#include<stdio.h>#include<algorithm>#include<iostream>#include<string.h>using namespace std;int main(){int n, m;while(scanf("%d %d", &n, &m) &

UVA10361- Automatic Poetry

題意:就是把兩個<>中的前後互換思路:就是比較麻煩,開四個數組分別存四個字串,之後在拼接。記得最後要加上' \0 '。#include<stdio.h>#include<string.h>int main(){int n, flag, k, l;char s[2][105];scanf("%d", &n);getchar();while (n--){char str[105], ss[105];char s1[20], s2[20], s3[20] ,

UVA10474-Where is the Marble?

水題。。。不過要注意輸出格式。。。#include<stdio.h>#include<string.h>#include<algorithm>#define N 10050using namespace std;int a[N], b[N];int main(){int n, m, t = 0, flag;while(scanf("%d%d", &n, &m) == 2 && (m || n)){memset(a, 0,

UVA537- Artificial Intelligence?

題意:算出所給的字串中的關鍵字符I,P,U,算出結果思路:自我感覺輸入有點蛋疼。。。。。分兩個部分輸入,詳情見代碼!!!!!#include<stdio.h>#include<string.h>int main(){int n, t = 0;char s[100];scanf("%d", &n);while (n--){int cnt = 0;double x, y;char str[2], ss[2];memset(s, 0, sizeof(s));while

UVA152-Tree’s a Crowd

題意:求各棵樹到其他樹的最短距離,然後記錄下來,距離只有0-9 思路:暴力把。。。直接搜尋,但要記住,最後的距離是向下取整,而不是向上取整,剛開始理解錯誤,用ceil取整距離,WA了好多次,後來才發現,直接用int強制轉化#include<stdio.h> #include<stdlib.h>#include<math.h> #include<string.h>int dis[11];struct space{double x, y,

UVA409- Excuses, Excuses!

題意:找出字串中關鍵字符最多的那串字元,如果關鍵字符相等,則相等的都要輸出思路:就是一個一個關鍵字符慢慢找,開一個vis數組,記錄每個字串的關鍵字符的數量,不斷更新。#include<stdio.h>#include<string.h>#include<ctype.h>char word[25][25], s[25][100], str[25][100];int vis[25];int n, m;void num(char *s, int

UVA591- Box of Bricks

題意:移動最少的磚,使所有堆的轉數量相同思路:其實不管怎麼樣肯定是要把高出平均值的磚堆拿出給低於平均值的轉堆,所有只要記錄要移動高出平均值的磚堆的磚頭就可以了#include<stdio.h>int main(){int n, sum, average, cnt, t = 0;int arr[55];while (scanf("%d", &n) && n){sum = 0;cnt = 0;for(int i = 0; i < n; i++){scanf(

UVA10719- Quotient Polynomial

思路:還是推公式,可以得到a[i + 1] -= b[i] * (-k);#include<stdio.h> #include<string.h>#include<stdlib.h>int main() {int k = 0, r;int a[10005], b[10005];while (scanf("%d", &k) != EOF) {int cnt = 0;char ch;memset(a, 0, sizeof(a));memset(b, 0,

UVA10420-List of Conquests

思路:只需比較前面國家的名稱就行了,記得要排序完再進行下一步操作,這樣比較方便!!!!!#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char cname[2005][80];char pname[2005][80];int compare(const void *a, const void *b){return strcmp((char *)a,

總頁數: 61357 1 .... 17113 17114 17115 17116 17117 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.