锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
2001.11.4鐨?鏈?鏃? 11 + 4 = 濂囨暟銆傘?/font> 鐢變簬鏃犺鏄湀鍔犱竴榪樻槸鏃ュ姞涓鏈堟棩鍜岀殑濂囧伓鎬?/font>閮戒細(xì)鍙戠敓鍙樺寲, 闄や簡(jiǎn)2.28銆?.30鍜?1.30. 2.28銆?.30銆?1.30鏄庢樉鏈夊繀鑳滅殑絳栫暐: 2.28->3.28, 9.30->10.1, 11.30->12.1 鎵浠ラ櫎浜?jiǎn)鍓╀綑鐨勪袱涓壱?guī)畩鐨勬儏鍐典互澶栵紝鍏朵綑鍙婊¤凍鏈?鏃ョ瓑浜庡伓鏁板氨鏈夊繀鑳滅殑絳栫暐銆?/font>
if(value!=w[i] && value!=w[j] && value!=w[k])
濡傛灉娌℃湁榪欏彞鍓灊灝變細(xì)瓚呮椂……
鍓灊寰堝己澶э綖
2 #include <algorithm>
3
4 using namespace std;
5
6 long w[1000];
7
8 int compare (const void * a, const void * b)
9 {
10 return ( *(int*)a - *(int*)b );
11 }
12
13 int main()
14 {
15 int N;
16 while (cin >> N && N!=0)
17 {
18 int found = false;
19
20 if (N<4)
21 {
22 cout << "no solution" << endl ;
23 continue ;
24 }
25 for (int i = 0; i < N; i++)
26 cin >> w[i];
27
28 qsort(w,(size_t)N,sizeof(long),compare);
29
30 for (int i = N - 1; i >=0; i--)
31 {
32 for (int k = N - 1; k >=0; k--)
33 {
34 if (i == k) continue;
35 for (int j = k - 1; j >=0; j--)
36 {
37 if (j == i) continue;
38 long value = w[i] - w[j] - w[k];
39 if(value!=w[i] && value!=w[j] && value!=w[k])
40 {
41 int mid ;
42 int beg = 0;
43 int end = N - 1;
44 bool searchfound = false;
45 while ( beg <= end )
46 {
47 mid = ( beg + end ) / 2 ;
48 if ( w[mid] > value )
49 end = mid-1 ;
50 else if ( w[mid] < value )
51 beg = mid+1 ;
52 else
53 {
54 searchfound = true;
55 break;
56 }
57 }
58 if (searchfound==true)
59 {
60 cout << w[i] << endl;
61 found = true;
62 goto out;
63 }
64 }
65 }
66 }
67 }
68 out:if (!found)
69 cout << "no solution" << endl;
70 }
71 return 0;
72 }
]]>
2
3 using namespace std;
4
5 int main()
6 {
7 int N;
8 cin >> N;
9 for (int i = 0;i < N; i++)
10 {
11 int yy,mm,dd;
12 cin >> yy >> mm >> dd;
13 bool flag = false;
14 if (mm==2 && dd==28)
15 flag = true;
16 else if (mm==9 && dd==30)
17 flag = true;
18 else if (mm==11 && dd==30)
19 flag = true;
20 else
21 {
22 if ((mm+dd)%2==0)
23 flag = true;
24 }
25 if (flag)
26 cout << "YES" << endl;
27 else
28 cout << "NO" << endl;
29 }
30 }
]]>
棰樼洰鐨勫ぇ鎰忔垜灝變笉璇翠簡(jiǎn)錛屽ぇ瀹惰嚜宸卞幓google涓涓嬪惂錛屾湁浜鴻榪囦簡(jiǎn)
灝辯畻閿葷偧浜?jiǎn)涓涓嬬敤vector,algorithm鍚?br />
綆楁硶寰堢畝鍗曪紝鍏堟寜鐓ф潵鐨勬椂闂村拰鎶ラ叕鎺掑簭
鐒跺悗鍦ㄤ竴涓竴涓殑澶勭悊錛屾湭澶勭悊鐨勫氨鍔犲叆鍒皊uspend閲岄潰錛岀瓑鍒頒笅涓杞鐞?br />
鏈変釜鍦版柟姣旇緝鐗規(guī)畩錛屽氨鏄負(fù)澶勭悊鐨勪換鍔★紝濡傛灉浠栫殑鎴鏃墮棿鍦‵涔嬪墠錛岄偅涔堜細(xì)綆楁儵緗氾紝濡傛灉瓚呭嚭浜?jiǎn)锛尀兏嵔帡浜?jiǎn)
鍒氬紑濮嬭繖涓湴鏂規(guī)病娉ㄦ剰錛屾墍浠ヨ礎(chǔ)鐚簡(jiǎn)鍑犳WA
2 #include <algorithm>
3 #include <vector>
4 using namespace std;
5
6 struct rect
7 {
8 public:
9 rect(int a,int b,int c,int d,int e,int f,int g):m_a(a),m_b(b),m_c(c),m_d(d),m_e(e),m_f(f),m_g(g){}
10 int m_a,m_b,m_c,m_d,m_e,m_f,m_g;
11 };
12
13 vector<rect> job,suspend;
14 vector<rect>::iterator it;
15
16 bool compare(rect a,rect b)
17 {
18 if (a.m_c<b.m_c)
19 return 1;
20 else if (a.m_c>b.m_c)
21 return 0;
22 else
23 {
24 if (a.m_e>b.m_e)
25 return 1;
26 else
27 return 0;
28 }
29 }
30
31 int main()
32 {
33 int F;
34 int Case = 1;
35
36 cin >> F;
37 while (F!=0)
38 {
39 int M,N,L;
40 cin >> M >> N >> L;
41
42 //count the number of job
43 int totaljob = 0;
44
45 //initialize
46 job.clear();
47 suspend.clear();
48
49 //input
50 for (int i = 0; i < L; i++)
51 {
52
53 int a,b,c,d,e,f,g;
54
55 cin >> a >> b >> c >> d >> e >> f >> g;
56
57 //Arraive before timeline
58 if (c<F)
59 {
60 rect *temp = new rect(a,b,c,d,e,f,g);
61 job.push_back(*temp);
62 totaljob++;
63 }
64 }
65
66 //sort the jobs according to the arriving time
67 sort(job.begin(),job.end(),compare);
68
69 it = job.begin();
70 long totalvalue = 0;
71
72 for (int time = 0; time < F; time++)
73 {
74 int mm = M;
75 int nn = N;
76
77 while (it != job.end() && time >= it->m_c)
78 {
79 suspend.push_back(*it);
80 it++;
81 }
82
83 vector<rect>::iterator temp;
84 temp = suspend.begin();
85
86 while (temp!=suspend.end())
87 {
88 if (mm>=temp->m_a && nn>=temp->m_b)
89 {
90 mm-=temp->m_a;
91 nn-=temp->m_b;
92 totalvalue+=temp->m_e;
93 if (time + 1< temp->m_d)
94 totalvalue+=temp->m_f*(temp->m_d - time - 1 );
95 else if (time + 1 > temp->m_d)
96 totalvalue-=temp->m_g*(time + 1 - temp->m_d);
97 suspend.erase(temp);
98 temp = suspend.begin();
99 }
100 else
101 temp++;
102
103 }
104 }
105
106 vector<rect>::iterator temp;
107
108 if (!suspend.empty())
109 {
110 for (temp = suspend.begin();temp!=suspend.end();temp++)
111 {
112 if (temp->m_d<=F)
113 totalvalue-=(F - temp->m_d)*temp->m_g;
114 }
115 }
116 //for (it = job.begin(); it!=job.end(); it++)
117 // cout << it->m_a << " " << it->m_b << " " << it->m_c << " " << it->m_d << " " << it->m_e
118 // << " " << it->m_f << " " << it->m_g << endl;
119
120
121
122 cout << "Case " << Case++ << ": " << totalvalue << endl << endl;
123 cin >> F;
124 }
125 return 0;
126 }
]]>
鍙﹀錛屾暟鎹噺寰堝ぇ錛岀敤cin浼?xì)瓒呮?br />
2 #include <cmath>
3
4 using namespace std;
5
6 int main()
7 {
8 int N;
9 cin >> N;
10 getchar();
11 for (int i = 0; i < N; i++)
12 {
13 double ka,b;
14 int m,n;
15 scanf("%lf %lf %d %d",&ka,&b,&m,&n);
16 //cin >> ka >> b >> m >> n;
17 while (ka!=0.0 && b!=0.0 && m!=0 && n!=0)
18 {
19 double x = ((-1)*ka+sqrt(ka*ka+4*m*n*ka*b))/(2*m*n);
20 double pH = -log10(m*x);
21 printf("%.3f\n",pH);
22 scanf("%lf %lf %d %d",&ka,&b,&m,&n);
23 //cin >> ka >> b >> m >> n;
24 }
25
26 if (i!=N-1) {
27 printf("\n");
28 getchar();
29 }
30 }
31 //system("pause");
32 return 0;
33 }
]]>
鐪嬩簡(jiǎn)鍗婂ぉ閮芥病鐪嬫噦棰樼洰鏄粈涔堬紝浜庢槸鐩存帴鎵句簡(jiǎn)涓涓兘榪囩殑浠g爜
鍚庢潵鍙戠幇鍘熸潵灝辨槸鎵捐繛緇殑涓婂崌錛屼笅闄嶇殑搴忓垪鐨勯暱搴︾殑騫沖潎鏁?br />
2
3 int upCount, downCount, pendingCount;
4 int numberOfUpSequences, numberOfDownSequences;
5
6 char state;
7
8 int thisValue, lastValue;
9
10 int main()
11 {
12 float avgUp, avgDown;
13 int done = 0;
14 int count;
15 while ( ! done )
16 {
17 state = 'S';
18 upCount = 0; downCount = 0; pendingCount = 0;
19 count = 0;
20 numberOfUpSequences = 0; numberOfDownSequences = 0;
21 while ( 1 )
22 {
23 scanf("%d", & thisValue);
24 if ( (state == 'S') && (thisValue == 0 ) )
25 {
26 done = 1;
27 break;
28 }
29 else if (thisValue == 0)
30 break;
31 switch ( state )
32 {
33 case 'S':
34 state = 'N';
35 break;
36 case 'N':
37 if ( thisValue == lastValue )
38 pendingCount++;
39 else if ( thisValue < lastValue )
40 {
41 state = 'D';
42 downCount = pendingCount + 1;
43 numberOfDownSequences++;
44 }
45 else if ( thisValue > lastValue )
46 {
47 state = 'U';
48 upCount = pendingCount + 1;
49 numberOfUpSequences++;
50 }
51 break;
52 case 'D':
53 if ( thisValue <= lastValue )
54 downCount++;
55 else if ( thisValue > lastValue )
56 {
57 state = 'U';
58 upCount++;
59 numberOfUpSequences++;
60 }
61 break;
62 case 'U':
63 if( thisValue >= lastValue )
64 upCount++;
65 else if ( thisValue < lastValue )
66 {
67 state = 'D';
68 downCount++;
69 numberOfDownSequences++;
70 }
71 break;
72 }
73 lastValue = thisValue;
74 count++;
75 }
76 if ( state != 'S' )
77 {
78 if ( numberOfUpSequences )
79 avgUp = (float)upCount/numberOfUpSequences;
80 else
81 avgUp = 0.0;
82 if ( numberOfDownSequences )
83 avgDown = (float)downCount/numberOfDownSequences;
84 else
85 avgDown = 0.0;
86 printf("Nr values = %d: ", count);
87 printf("%f %f\n", avgUp, avgDown );
88 }
89 }
90 }
91
92
]]>
涓涓悓浣欑殑闂
(a * b + c) % n=[ (a % n) * b + c] % n
鍛冿紝鐪嬭搗鏉ラ兘鏈夌偣鍍忓父璇嗕簡(jiǎn)錛屽彲鏄繕鏄笉浼?xì)锛屽ぇ姒傞珮?shù)腑鐨勬椂鍊欏氨娌″濂?br />
2
3 using namespace std;
4
5 int main(){
6 int n,rem,digs;
7 while (cin >> n) {
8 for (rem=digs=1;rem%n!=0;digs++) rem = (rem*10+1) % n;
9 printf("%d\n",digs);
10 }
11 return 0;
12 }
13
]]>
妯℃嫙闂錛?br />
1006 1009 1012 1016 1019 1023 1026 1028 1038 1042 1045 1051 1056 1057 1058 1061 1065 1066 1068 1072 1073 1078 1087 1088 1097 1098 1099 1103 1111 1121 1124 1126 1128 1133 1138 1146 1152 1154 1160 1175 1178 1187 1194 1207 1222 1224 1244 1259 1267 1274 1275 1277 1278 1279 1281 1282 1294 1295 1300 1308 1317 1324 1339 1351 1362 1392 1393 1397 1398 1399 1400 1402 1432 1434 1444 1452 1475 1487 1493 1497 1517 1526 1527 1530 1531 1552 1569 1573 1592 1601 1610 1623 1631 1641 1652 1657 1659 1682 1692 1700 1702 1707 1708 1712 1728 1732 1737 1746 1747 1750 1752 1754 1758 1764 1768 1774 1797 1799 1804 1807 1811 1822 1824 1831 1834 1837 1838 1842 1844 1845 1854 1858 1862 1870 1881 1884 1889 1896 1906 1921 1951 1969 1978 2000 2022 2040 2046 2047 2051 2072 2084 2101 2112 2131 2133 2138 2148 2153 2156 2160 2164 2172 2178 2184 2185 2187 2189 2193 2196 2201 2204 2208 2211 2212 2220 2229 2233 2239 2240 2261 2262 2269 2277 2288 2301 2309 2311 2312 2316 2320 2321 2322 2328 2330 2350 2389 2405 2410 2414 2420 2421 2483 2508 2560 2569 2572 2593 2613 2617 2680 2681 2731 2732 2743
鍔ㄦ佽鍒掞細(xì)
1013 1022 1025 1027 1074 1076 1093 1094 1100 1107 1108 1136 1149 1183 1196 1200 1206 1227 1234 1245 1249 1250 1276 1303 1346 1353 1366 1368 1387 1424 1425 1428 1446 1448 1449 1454 1459 1462 1463 1470 1474 1475 1483 1484 1490 1499 1503 1512 1515 1520 1524 1539 1540 1554 1563 1567 1579 1602 1607 1611 1629 1638 1642 1651 1666 1695 1713 1717 1731 1733 1736 1738 1743 1756 1757 1787 1792 1800 1819 1853 1864 1877 1880 1893 1913 1918 1925 1953 1985 1986 1988 1991 1995 2002 2014 2025 2042 2058 2059 2067 2068 2069 2081 2096 2127 2136 2142 2144 2156 2180 2189 2202 2206 2213 2224 2227 2242 2244 2254 2255 2264 2271 2278 2280 2281 2283 2284 2297 2319 2337 2338 2341 2349 2353 2354 2366 2372 2374 2397 2401 2402 2414 2422 2424 2432 2498 2501 2521 2522 2527 2536 2547 2561 2563 2565 2568 2581 2591 2598 2604 2621 2624 2625 2626 2641 2642 2667 2673 2683 2685 2692 2702 2710 2711 2734 2739 2744 2745
瀛楃涓插鐞嗛棶棰橈細(xì)
1002 1004 1005 1008 1016 1019 1046 1048 1049 1050 1051 1052 1053 1054 1055 1056 1061 1063 1086 1089 1091 1094 1099 1101 1103 1111 1115 1117 1118 1120 1123 1125 1126 1129 1130 1136 1139 1143 1150 1151 1152 1154 1159 1160 1168 1170 1177 1178 1179 1180 1181 1184 1188 1189 1190 1191 1192 1195 1197 1243 1295 1315 1325 1392 1582 1698 1707 1720 1729 1808 1831 1854 1858 1905 1963 1969 1970 1984
鎼滅儲(chǔ)闂錛?br />
1002 1003 1008 1031 1038 1039 1041 1060 1063 1069 1080 1083 1088 1089 1103 1144 1155 1190 1204 1217 1229 1249 1297 1301 1344 1355 1361 1412 1415 1435 1443 1457 1479 1505 1518 1530 1593 1649 1671 1675 1686 1709 1711 1719 1742 1832 1909 1935 1940 1977 1984 2031 2033 2043 2053 2093 2103 2110 2128 2165 2233 2241 2252 2276 2288 2355 2372 2374 2412 2416 2418 2437 2440 2442 2466 2471 2475 2477 2509 2515 2531 2534 2580 2588 2594 2631 2633 2688
鏁拌闂錛?br />
1007 1028 1088 1113 1133 1160 1222 1278 1284 1312 1314 1385 1489 1526 1530 1569 1577 1596 1601 1652 1657 1712 1797 1842 1889 1906 1951 2000 2022 2028 2060 2095 2105 2156 2189 2212 2233 2277 2288 2305 2316 2320 2330 2360 2371 2400 2410 2414
鍑犱綍闂錛?br />
1010 1032 1037 1041 1081 1090 1104 1123 1139 1165 1199 1426 1439 1460 1472 1597 1608 1648 1683 1910 2015 2102 2107 2157 2228 2234 2318 2335 2347 2352 2361 2370 2375 2394 2403
鏍?wèi)鍨嬀l撴瀯闂錛?br />
1011 1038 1043 1062 1141 1159 1167 1203 1319 1335 1387 1406 1481 1511 1542 1586 1610 1635 1674 1700 1752 1788 1805 1809 1900 1944 1955 1959 1965 1990 2243 2425
鍥捐〃闂錛?br />
1015 1030 1082 1084 1085 1105 1119 1127 1130 1140 1203 1311 1377 1420 1453 1465 1492 1589 1798 1802 1919 1935 2016 2236 2238 2281 2326
鍖歸厤闂錛?br />
1002 1059 1077 1137 1140 1157 1197 1231 1364 1516 1525 1576 1626 1654 1882 2067 2192 2221 2223 2333 2362 2404
璐績(jī)闂錛?br />
1025 1029 1076 1117 1161 1239 1360 1543 2049 2091 2109 2315 2343 2425
鏈鐭礬闂錛?br />
1298 1333 1456 1589 1721 1942 1952
鍗氬紙闂錛?024 1134 1893 1913
鏈澶ф祦闂錛?734 1992 2314
鍏朵粬闂錛?br />
1021 1046 1069 1070 1073 1177 1245 1262 1292 1294 1309 1334 1354 1389 1391 1423 1440 1475 1551 1584 1610 1636 1716 1717 1926 1929 1948 1954 1958 1962 1985 1986 1990 2132 2313 2320
]]>
寰堢畝鍗曠殑棰樼洰錛岄鎰忔垜灝變笉璇翠簡(jiǎn)
涓轟簡(jiǎn)瀹屾垚鍙嶅悜浜ゆ崲錛屾渶灝戠殑鍔炴硶灝辨槸浠庝竴鐐規(guī)妸鎵鏈変漢鍒嗘垚涓ょ粍
鐒跺悗姣忎釜緇勮繘琛屽弽鍚戜氦鎹紝鏈鍚庡姞璧鋒潵灝辨槸
濡傛灉鏌愪竴鐐歸渶瑕佷氦鎹㈠埌璺濈鑷繁鐨勮窛紱昏秴榪噉/2鏃訛紝閭e氨鍙互鏀懼埌鍙﹀涓緇勶紝寰楀埌鐨勪氦鎹㈡楠よ偗瀹氭瘮杈冨皯
涓嶇煡閬撹娓呮浜?jiǎn)娌℃?#8230;…
浠g爜鍦ㄥ埆浜洪偅閲岀湅鍒扮殑錛屾渶寮濮嬭嚜宸卞仛鐨勯掓帹鍏紡閿欎簡(jiǎn)……
2 using namespace std;
3
4 int d(int n)//鎳傚緱鍘熺悊,灝辨槸涓涓畻鏁?/span>
5 {
6 int i,t=0;
7 for(i=1;i<n;i++)
8 t+=i;
9 return t;
10 }
11
12 int main()
13 {
14 int n,i,a,p;
15 while(cin>>n)
16 {
17 for(i=0;i<n;i++)
18 {
19 cin>>a;
20 p=d(a/2)+d(a-a/2);//綆楀紡
21 cout<<p<<endl;
22 }
23 }
24 return 0;
25 }
]]>
f(n,m)=max{f(n-1,m), f(n-1,m-w[n])+P(n,m)}
Sample Code