• hdu--1869--见过最好听的题名<附送1870>


    发现最近 忘记写了 题目链接 我的错 =-=

    我现在 开始直接随机点一套题目来做 这样 的最大好处就是 你不知道是什么算法来做 这样很好

    六度分离 名字 真的很好听 =-=

    但 题目 想到了 就蛮简单的 就是个 最短路 用floyd 这题 最方便     touch me

     1 #include <iostream>
     2 using namespace std;
     3 
     4 int n , m;
     5 const int size = 105;
     6 const int inf = 0x3f3f3f3f;
     7 int mp[size][size];
     8 
     9 void init( )
    10 {
    11     for( int i = 0 ; i<size ; i++ )
    12     {
    13         for( int j = 0 ; j<=i ; j++ )
    14         {
    15             if( i==j )
    16                 mp[i][j] = 0;
    17             else
    18                 mp[i][j] = mp[j][i] = inf;
    19         }
    20     }
    21 }
    22 
    23 void floyd( )
    24 {
    25     for( int k = 0 ; k<n ; k++ )
    26     {
    27         for( int i = 0 ; i<n ; i++ )
    28         {
    29             for( int j = 0 ; j<n ; j++ )
    30             {
    31                 if( mp[i][k]+mp[k][j] < mp[i][j] )
    32                     mp[i][j] = mp[i][k] + mp[k][j];
    33             }
    34         }
    35     }
    36 }
    37 
    38 int main()
    39 {
    40     cin.sync_with_stdio(false);
    41     int x , y;
    42     bool flag;
    43     while( cin >> n >> m )
    44     {
    45         flag = true;
    46         init( );
    47         while( m-- )
    48         {
    49             cin >> x >> y;
    50             mp[x][y] = mp[y][x] = 1;
    51         }
    52         floyd( );
    53         for( int i = 0 ; i<n ; i++ )
    54         {
    55             for( int j = 0 ; j<n ; j++ )
    56             {
    57                 if( mp[i][j] >7 )
    58                 {
    59                     flag = false;
    60                     break;
    61                 }
    62             }
    63             if( !flag )
    64                 break;
    65         }
    66         if( flag )
    67             cout << "Yes" << endl;
    68         else
    69             cout << "No" << endl;
    70     }
    71     return 0;    
    72 }
    View Code

    我一开始 以为这套题 的 最后一题是最难的 我还是太天真了

    做完后 面对自己起初的猜测 无言以对

    太水了 直接上        touch  me

     1 #include <iostream>
     2 using namespace std;
     3 
     4 char str[1010];
     5 
     6 int main()
     7 {
     8     int ans;
     9     while( cin >> str )
    10     {
    11         ans = 0;
    12         for( int i = 0 ; str[i]!='' ; i++ )
    13         {
    14             if( str[i] == '(' )
    15                 ans ++;
    16             else if( str[i] == ')' )
    17                 ans --;
    18             else
    19                 break;
    20         }
    21         cout << ans << endl;
    22     }
    23     return 0;
    24 }
    View Code
    just follow your heart
  • 相关阅读:
    ubuntu配置实验
    初始linux系统--ubuntu
    部署WSUS服务(一)
    web站点启用https (二)
    web站点启用https (一)
    windows 域的安装方法
    链表大合集(一)
    神奇的幻方
    二叉树的存储结构 以及重建二叉树
    html列表
  • 原文地址:https://www.cnblogs.com/radical/p/3916478.html
Copyright © 2020-2023  润新知