codeforces #284

来源:互联网 发布:java ftp上传附件 编辑:程序博客网 时间:2024/06/07 17:44
<pre name="code" class="cpp">A.#include <iostream>#include <cstdio>using namespace std;#define maxn 55struct Time{    int L,R;}b[maxn];int main(){    int n,m;    while(~scanf("%d%d",&n,&m))    {        int cnt=0;        for(int i=0; i<n; i++)        {            cin>>b[i].L>>b[i].R;        }        for(int i=0; i<n-1; i++)        {            int t=(b[i+1].L-b[i].R-1)/m;            cnt+=t;        }        int t=(b[0].L-1)/m;        cnt+=t;        cout<<b[n-1].R-cnt*m<<endl;    }    cout<<endl;    return 0;}


B.#include <iostream>#include <cstdio>#include <cstring>#include <map>using namespace std;int main(){        map<string, string> rep;        string st1,st2;        int n,m;        while(~scanf("%d%d",&n,&m))        {            for(int i=0; i<m; i++)            {                cin>>st1>>st2;                rep[st1]=st2;            }            for(int i=0; i<n; i++)            {                cin>>st1;               if(st1.length()>rep[st1].length())                cout<<rep[st1];               else cout<<st1;               if(i<n-1) cout<<" ";            }            cout<<endl;        }        return 0;}
C.#include <iostream>#include <cstdio>#include <cstring>using namespace std;long long x1,y1,x2,y2;int main(){    cin>>x1>>y1;    cin>>x2>>y2;    long long n,a,b,c;    cin>>n;    int cnt=0;    for(int i=0; i<n; i++)    {        long long temp1, temp2;        cin>>a>>b>>c;            temp1=a*x1+b*y1+c;            temp2=a*x2+b*y2+c;            if((temp1<0&&temp2>0)||(temp1>0&&temp2<0))//这样处理不会溢出                cnt++;    }    cout<<cnt<<endl;    return 0;}


0 0
原创粉丝点击