Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

AC

Posted by shenyi0828 at 2009-03-05 14:40:00 on Problem 1552
In Reply To:边看电影边写代码,竟然一次 0 MS AC,黄河之水天上来~ Posted by:gfedcba at 2009-01-12 22:40:27
#include <iostream>
#include <vector>
using namespace std;

void input();
void solve();

vector<int> list;
vector<int> listD;
int tmp;

int main() 
{
    while (cin>>tmp) {
          if (tmp==-1) break;
          list.push_back(tmp);
          input();
          solve();
          list.clear();
          listD.clear();
    }
    return 0;
}
    
void input() {
     while (cin>>tmp) {
           if (tmp==0) return;
           else list.push_back(tmp);
     }
}

void solve() {
     int res=0;
     for (int i=0;i<list.size();i++) {
         listD.push_back(list[i]*2);
     }
     for (int i=0;i<list.size();i++) {
         for (int j=0;j<listD.size();j++) {
             if (list[i]==listD[j]) res++;
         }
     }
     cout<<res<<endl;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator