Hangzhou Electric School Race (crying ... )

Source: Internet
Author: User
Tags cmath

Wrote a half-day writing three water questions ... Abuse cry ....

The country List

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 0 Accepted Sub Mission (s): 0

Problem Descriptionas the World Expo hosted by Shanghai are coming, CC is very honorable to BES a volunteer of such an International pageant. The foreign visitors. Although he has a strong desire to is an excellent volunteer, the lack of 中文版 makes him annoyed for a long time.Some countries ' names look so similar that he can ' t distinguish them. Such As:albania and Algeria. If the countries ' names has the same length and there is more than 2 same letters in the same position of each word, CC Cannot distinguish them. For Example:albania and AlgerIa has the same length 7, and their first, second, sixth and seventh letters are same. So CC can ' t distinguish them. Now he have received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters is case-insensitive.

Inputthere is multiple test cases. Each case begins with a integer n (0 < n <) indicating the number of countries in the list. The next n lines each contain a country ' s name consisted by ' a ' ~ ' Z ' or ' a ' ~ ' Z '. Length of each word would not exceed 20. You can assume that no name would show up twice in the list.

Outputfor each case, output the number of hard names in CC ' s list.

Sample Input3denmarkgermanychina4aaaaabaacbaacbad

Sample Output24

Water problem. Let's judge the number of indistinguishable strings;

Code:

#include <cstdio> #include <cmath> #include <cstring> #include <iostream> #include <vector > #include <map> #include <queue>const int inf=0x3f3f3f3f; #define MEM (x, y) memset (x,y,sizeof) #define PI (x) printf ("%d", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &x) #define PL (x) printf ("%lld", X) typedef long Long ll;using namespace std;struct Node{char s[25];int len; BOOL JS (Node A,node b) {int temp=0;for (int i=0;i<a.len;i++) {if (a.s[i]==b.s[i]| | ABS (a.s[i]-b.s[i]) = = ' A '-' a ') temp++;if (temp>2) return true; return false;} Node Dt[110];int Main () {int n;while (~scanf ("%d", &n)) {for (int i=0;i<n;i++) scanf ("%s", Dt[i].s), dt[i].len= Strlen (DT[I].S); int ans=0;for (int i=0;i<n;i++) {for (int j=0;j<n;j++) {if (i==j| | Dt[i].len!=dt[j].len) continue;if (JS (dt[i],dt[j])) {Ans++;break;}}} printf ("%d\n", ans);} return 0;}

  

Happy Value

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 0 Accepted Sub Mission (s): 0

Problem DescriptionIn an apartment, there is N residents. The Internet Service Provider (ISP) wants to connect these residents with n–1 cables.However, the friendships of the residents is different. There is a "Happy Value" indicating the degrees of a pair of residents. The higher "Happy Value" is, the friendlier a pair of residents are. So the ISP wants to choose a connecting plan to make the highest sum of "Happy Values".

Inputthere is multiple test cases. Please process to end of file. The first line contains only one integer N (2<=n<=100), indicating the number of the residents. Then N lines follow. Each line contains N integers. Each integer Hij (0<=hij<=10000) in ithrow and jth column indicates that ith resident has a "Happy Value" Hij with jth resident. and Hij (i!=j) is equal to Hji. Hij (i=j) is always 0.

Outputfor each case, please output the answer on one line.

Sample Input20 11 030 1 51 0 35 3 0

Sample Output18

Puzzle: Minimum spanning tree template problem, oh, is the largest;

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <vector > #include <map> #include <queue>using namespace std;const int inf=0x3f3f3f3f; #define MEM (x, y) memset (x, y , sizeof (x)) #define PI (x) printf ("%d", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &x) #define PL (x ) printf ("%lld", x) typedef long LONG ll;const int maxn=110;int mp[maxn][maxn];int ans;int n;int low[maxn];int vis[maxn];vo ID Prim () {mem (low,inf); mem (vis,0); for (int i=1;i<=n;i++) Low[i]=mp[1][i];vis[1]=1;while (true) {int temp=-inf,k; for (int i=1;i<=n;i++) if (!vis[i]&&low[i]>temp) temp=low[k=i];if (temp==-inf) break;vis[k]=1;ans+=temp ; for (int i=1;i<=n;i++) if (!vis[i]) Low[i]=max (Low[i],mp[k][i]);}} int main () {while (~SCANF ("%d", &n)) {for (Int. i=1;i<=n;i++) for (int j=1;j<=n;j++) {SI (mp[i][j]);} Ans=0;prim ();p rintf ("%d\n", ans); return 0;}

  

The Magic Tower

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 0 Accepted Sub Mission (s): 0

Problem Descriptionlike Most of the RPG (role play game), ' The Magic Tower ' is a game on how a warrior saves the Prince Ss.After killing lots of monsters, the warrior have climbed up the top of the Magic Tower. There is a boss in front of him. The warrior must kill the boss to save the princess. Now, the warrior wants-to-tell him if he can save the princess.

Inputthere is several test cases. For each case, the first line was a character, "W" or "B", indicating that who begins to attack first, "W" for Warrior and "B" for boss. They attack each and turn.The second line contains three integers, w_hp, w_atk and W_def. (1<=w_hp<=10000, 0<=W_ATK, w_def<=65535), Indi Cating Warrior ' s life point, attack value and defense value. The third line contains three integers, b_hp, b_atk and B_def. (1<=b_hp<=10000, 0<=B_ATK, b_def<=65535), Indicating boss's life point, attack value and defense value.
Note:warrior can make a damage of (w_atk-b_def) to Boss if (w_atk-b_def) bigger than zero, otherwise no damage. Also, boss can make a damage of (b_atk-w_def) to Warrior if (b_atk-w_def) bigger than zero, otherwise no damage.  

Outputfor each case, if boss's HP first turns to being smaller or equal than zero, please print "Warrior wins". Otherwise, please print "Warrior loses". If Warrior cannot kill the boss forever, please also print "Warrior loses".

Sample InputW100 900100 900b100 1000 900100 1000 900

Sample Outputwarrior Winswarrior loses

Water problem, how much time to find out, pay attention to the case of 0 of the special sentence;

Code:

#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <vector > #include <map> #include <queue>using namespace std;const int inf=0x3f3f3f3f; #define MEM (x, y) memset (x, y , sizeof (x)) #define PI (x) printf ("%d", x) #define SI (x) scanf ("%d", &x) #define SL (x) scanf ("%lld", &x) #define PL (x ) printf ("%lld", x) typedef long long Ll;const double dot=0.999999999999999;int main () {char s[2];int w_h,w_a,w_d,b_h,b_a, B_d;while (~scanf ("%s", s)) {scanf ("%d%d%d%d%d%d", &w_h,&w_a,&w_d,&b_h,&b_a,&b_d); int t1,t2 ; if (w_a<=b_d) {puts ("Warrior loses"); continue;} if (b_a<=w_d) {puts ("Warrior wins"); continue;} t1= (int) dot+b_h/(w_a-b_d), t2= (int) dot+w_h/(b_a-w_d), int flot=0;if (s[0]== ' W ') flot=1;if (T1>T2) puts ("Warrior Loses "), else if (T1==t2&&!flot) puts (" Warrior loses "); else puts (" Warrior wins ");} return 0;}

  

Hangzhou Electric School Race (crying ... )

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.