2015 C Language Program design Competition (junior group), Jiangxi University of Technology

Source: Internet
Author: User

Janktao Blind Date

Solution: Sort

#include <stdio.h> #include <string.h> #include <iostream> #include <math.h> #include <map > #include <set> #include <vector> #include <algorithm>using namespace std;const double INF = 1e20; Const double PI = ACOs ( -1.); int main () {    int t;    int a[100];    while (Cin>>t)    {while        (t--)        {for        (int i=0;i<11;i++)        {            cin>>a[i];        }        Sort (a,a+11);        printf ("%d\n", a[9]);        }    }    return 0;}
David's path to the desert

Solution: Greedy, as far as possible to go to the maximum distance, plus it experienced the largest gas station, simulation of this process need to consider a lot of circumstances

#include <iostream> #include <stdio.h> #include <queue>using namespace std;struct cmp{bool operator ()    (int &a,int &b)    {return a<b;    }};struct node{int x, y,} e[1005];int main () {priority_queue<int,vector<int>,cmp>que;    int T;    scanf ("%d", &t);        while (t--) {int n,l,s,x,y,cnt=0,flag=0,f=0;        scanf ("%d%d%d", &n,&l,&s);        for (int i=0; i<n; i++) {scanf ("%d%d", &e[i].x,&e[i].y);        } e[n].x=0,e[n].y=l;            for (int i=0; i<=n; i++,f=0) {x=e[i].x,y=e[i].y;                if (y<=s) {que.push (x);                f=1;                The longest can span the number of gas stations, put them in the queue} while (Y>=s) {if (s>=l) break;                    if (!f && s==y) {que.push (x);                    f=1;             Not across, just good to arrive}   if (Que.empty ()) {printf ("tj\n");                    flag=1;                Break                } int xx=que.top ();//Take the nearest gas station Que.pop ();                S+=xx;            cnt++;            } if (!f) Que.push (x);                if (s>=l) {printf ("%d\n", CNT);                flag=1;            Break        } if (flag) break;        } if (!flag) printf ("tj\n");    while (!que.empty ()) Que.pop (); } return 0;}
TJ's File system

Solution: String Processing

#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define Lson l,m,rt<<1#define Rson m+1,r,rt<    <1|1#define LL long longusing namespace Std;const int maxn = 22;int Main () {int t;    int n;    int i;    Int J;    String S,ss;            while (cin>>t) {while (t--) {string sss= "";            int ans;            cin>>n>>s;                for (i=0;i<n;i++) {string sss= "";                cin>>ss;             Ans=ss.find (".");                cout<<ans<<endl;                For (J=ans+1;j<ss.length (); j + +) {Sss+=ss[j];                }//cout<<sss<<endl;            if (sss==s) {        cout<<ss<<endl; }}}} return 0;}
Handshake theorem

Solution: Water Problem

#include <stdio.h>int main () {    int SEQ, ACK1, ACK2, T;    scanf ("%d", &t);    while (t--)    {        scanf ("%d%d%d", &seq, &ack1, &ack2);        if ((ACK1 = = SEQ + 1) && (ACK2 = = ACK1 + 1))        {            printf ("qwn3213\n");        }        else            printf ("tj\n");    }    return 0;}
Alice and Bob

Solution: Simulation

#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define Lson l,m,rt<<1#define Rson m+1,r,rt<    <1|1#define LL Long longusing namespace Std;int a[100000],b[100000],c[100000];int main () {int t;    int i,j;    int n,m;    int x, y;    int k;    cin>>t;        while (t--) {k=0;        cin>>n>>m;        memset (A,0,sizeof (a));        Memset (b,0,sizeof (b));            for (i=0;i<n;i++) {cin>>x;        a[x]++;            } for (i=0;i<m;i++) {cin>>y;        b[y]++;       } for (i=0;i<100000;i++) {if (a[i]&&b[i]) c[k++]=i; } for (i=0;i<k;i++) {if (i==0) {printf ("%d", c[I]);            } else {printf ("%d", c[i]);    }} cout<<endl; } return 0;}
Building Group Data

Solution: String Processing time

#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <vector> #include <algorithm> #include <limits.h> #define INF 0x3fffffff#define Lson l,m,rt<<1#define Rson m+1,r,rt<    <1|1#define LL Long longusing namespace std;struct p{int number; int HHMMSS;}    Hehe[100000];int CMP (P a,p b) {if (A.number==b.number) return a.hhmmss<b.hhmmss; else return a.number<b.number;}    String s,ss,sss,ssss;string sssss;int t,n;int a;int i,j;int ans;int poi;int num;int Main () {cin>>t;        while (t--) {poi=1;        cin>>n;            for (i=0;i<n;i++) {cin>>a>>s;            Hehe[i].number=a;            Ss=s.substr (0,2);            Sss=s.substr (2,2);            Ssss=s.substr (4,2);  cout<<ss<< "" <<sss<< "" <<ssss<<endl;          Hehe[i].hhmmss= ((ss[0]-' 0 ') *10+ (ss[1]-' 0 ') * * *3600+ ((sss[0]-' 0 ') *10+ (sss[1]-' 0 ')) *60+ ((ssss[0]-' 0 ') *10+ (ssss[1        ]-' 0 ');        } cin>>sssss;        Ss=sssss.substr (0,2);        Sss=sssss.substr (2,2);        Ssss=sssss.substr (4,2);        Ans= ((ss[0]-' 0 ') *10+ (ss[1]-' 0 ')) *3600+ ((sss[0]-' 0 ') *10+ (sss[1]-' 0 ')) *60+ ((ssss[0]-' 0 ') *10+ (ssss[1]-' 0 '));        Sort (hehe,hehe+n,cmp);        NUM=HEHE[0].HHMMSS; for (int i=1;i<n;i++) {if (hehe[i].number!= hehe[i-1].number| |                Hehe[i].hhmmss-num>ans) {poi++;            NUM=HEHE[I].HHMMSS;    }} printf ("%d\n", poi); } return 0;}

  

2015 C Language Program design Competition (junior group), Jiangxi University of Technology

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.