zoukankan      html  css  js  c++  java
  • URAL 1880 Psych Up's Eigenvalues

    1880. Psych Up's Eigenvalues

    Time limit: 0.5 second
    Memory limit: 64 MB
    At one of the contests at the Petrozavodsk Training Camp, players of the Psych Up team quickly found the simple problem and Fedya sat at the computer. The solution was ready in five minutes. Without spending time for testing, Fedya submitted it and in a few seconds got Time Limit Exceeded.
    Fedya crumpled the problem statement and left the room slamming the door behind him. Things were going the wrong way and he needed to wind down. On his way to the restroom Fedya heard a conversation of the contest authors. Pasha was discussing with his friend the solution of the problem for which Fedya had got TLE. Fedya could only discern the word “eigenvalues.”
    Fedya thought about it and decided that he, for sure, had his eigenvalues. For example, the date of birth, the number of his apartment, the mark he had got at the latest exam, or the number of travels to contests. But they had a team contest, so what was their team's eigenvalue? Of course, a number was a team's eigenvalue if it was an eigenvalue for each of its players. With these joyful thoughts Fedya returned to the contest room.

    Input

    The input data consist of three blocks two lines each. The first line of each block contains the number n of a player's eigenvalues (1 ≤ n ≤ 4 000). In the second line you are given n distinct integers in ascending order, which are the eigenvalues. All the eigenvalues are positive integers not exceeding 109.

    Output

    Output the number of eigenvalues of the Psych Up team.

    Sample

    inputoutput
    5
    13 20 22 43 146
    4
    13 22 43 146
    5
    13 43 67 89 146
    
    3
     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;  
    15 int a[4010],b[4010],c[4010];  
    16 int main()  
    17 {  
    18      int t1 = 0, t2 = 0, t3 = 0;  
    19      cin>>t1;   
    20      for(int i= 0; i < t1; i++)  
    21      cin>>a[i]; 
    22      cin>>t2;   
    23      for(int i = 0; i < t2; i++)    
    24      cin>>b[i];   
    25      cin>>t3;   
    26      for(int i=0;i<t3;i++) 
    27      cin>>c[i];  
    28      int m=0; 
    29      int i=0,j=0,k=0; 
    30      while(i<t1&&j<t2&&k<t3)  
    31      {  
    32      int t = min(a[i], min(b[j], c[k]));  
    33      if (t == a[i] && t == b[j] && t == c[k]) 
    34      m++, i++, j++, k++;  
    35      else if (t == a[i]) 
    36      i++;  
    37      else if (t == b[j])
    38      j++;  
    39      else
    40      k++;  
    41      }  
    42      printf("%d
    ",m);
    43      return 0;  
    44 }  
    View Code
  • 相关阅读:
    JVM 垃圾收集与内存分配
    JVM 内存管理机制
    JVM 启动调优总结
    Visual Studio 2019 秘钥
    dubbo初学采坑记
    Intellij idea 一个窗口打开多模块并添加依赖
    Intellij idea 自动生成serialVersionUID
    office visio 2019 下载激活
    ASP.NET Core中的配置
    electron快捷键
  • 原文地址:https://www.cnblogs.com/qscqesze/p/3854183.html
Copyright © 2011-2022 走看看