2000年清華大學電腦研究生機試真題

來源:互聯網
上載者:User

標籤:

題目串連:點擊開啟連結


解題思路:

不可以用cin,會逾時

完整代碼:

#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");   }}

題目串連:點擊開啟連結


解題思路:

暴力枚舉

完整代碼:

#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 * 100 + j * 10 + k;                int b = j * 100 + k * 10 + k;                if(a + b == 532)                {                    cout << i << " " << j << " " << k << endl;                }            }        }    }}

題目串連:點擊開啟連結


解題思路:

枚舉

完整代碼:

#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 <= 60 ; 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" : " ");}

題目串連:點擊開啟連結


解題思路:

排序

完整代碼:

#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;const 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年清華大學電腦研究生機試真題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.