2000, Tsinghua University computer Research Life Test real problem

Source: Internet
Author: User

Topic Connection: Click to open link


Problem Solving Ideas:

Can not use CIN, will time out

Full code:

#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set >using namespace Std;const int INF = 1000000000;const int maxn = 10001; Char S[maxn];int main () {   #ifdef doubleq   freopen ("In.txt", "R", stdin);   #endif//Doubleq while    (~scanf ("%s", s))   {        int len = strlen (s);        for (int i = len-1; I >= 0; i-)            printf ("%c", S[i]);        printf ("\ n");}   }

Topic Connection: Click to open link


Problem Solving Ideas:

Brute Force enumeration

Full code:

#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set >using namespace Std;const int INF = 1000000000;const int maxn = 10001; Char S[maxn];int main () {/*   #ifdef doubleq   freopen ("In.txt", "R", stdin);   #endif//Doubleq   */for (int i = 0; I <= 9; i + +)    {for        (int j = 0; J <= 9; j + +)        {for            (int k = 0; K <= 9; K + +)            {                int a = i * + j * + K;                int B = J * + K * + K;                if (A + b = = 532)                {                    cout << i << "" << J << "" << k << Endl;                }            }        }    }}

Topic Connection: Click to open link


Problem Solving Ideas:

Enumeration

Full code:

#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <set >using namespace Std;const int INF = 1000000000;const int maxn = 10001;int a[101], b[101];    int check (int key) {int sum = 0;    for (int i = 1; i < key; I + +) {if (key% i = = 0) sum + = i;    } if (sum = = key) return 1;    else if (Sum > Key) return 2;  else return 0;}   int main () {/* #ifdef Doubleq freopen ("In.txt", "R", stdin);   #endif//Doubleq */int cnt1 = 0, Cnt2 = 0;        for (int i = 2; I <=; i + +) {if (check (i) = = 1) {a[cnt1++] = i;   } else if (check (i) = = 2) b[cnt2++] = i;   } cout << "E:"; for (int i = 0; i < cnt1; i + +) printf ("%d%s", a[i], i = = cnt1-1?    "\ n": "");    cout << "G:"; for (int i = 0; i < cnt2; i + +) printf ("%d%s", b[i], i = = cnt2-1? "\ n": "");}

Topic Connection: Click to open link


Problem Solving Ideas:

Sort

Full code:

#include <functional> #include <algorithm> #include <iostream> #include <fstream> #include < sstream> #include <iomanip> #include <numeric> #include <cstring> #include <climits># Include <cassert> #include <complex> #include <cstdio> #include <string> #include <vector > #include <bitset> #include <queue> #include <stack> #include <cmath> #include <ctime> #include <list> #include <set> #include <map>using namespace std; #pragma COMMENT (linker, "/stack:102400000,102400000") typedef long long ll;typedef double db;typedef unsigned uint; typedef unsigned long long ULL; /** Constant List. **///{const int MOD = INT (1e9) +7;const int INF = 0x3f3f3f3f;const LL inff = 0x3f3f3f3f3f3f3f3fll;const DB EPS = 1e-9;con St db OO = 1e20;const db PI = ACOs (-1.0); M_PI;    struct node{string s;    int old; int score;} Q[1000001]; BOOL CMP (Node A, Node B) {if (A.score! = B.score) RetuRN A.score > B.score;    else if (a.s! = B.S) return a.s > B.S;  else return a.old > b.old;}    int main () {#ifdef Doubleq freopen ("In.txt", "R", stdin);    #endif int n;            while (~SCANF ("%d", &n)) {for (int i = 0; i < n; i + +) {cin >> q[i].s;        scanf ("%d%d", &q[i].old, &q[i].score);        } sort (q, q + N, CMP);  for (int i = n-1; I >= 0; I-) {cout << q[i].s << "<< q[i].old <<" "        << Q[i].score << Endl; }    }}


2000, Tsinghua University computer Research Life Test real problem

Related Article

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.