• tese_Time_2h


    Relic Discovery HDU - 5982

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main(){
    	int t; scanf("%d",&t);
    	while(t--){
    		int n,a,b,ans=0; scanf("%d",&n);
    		for(int i=1; i<=n; i++){
    			scanf("%d%d",&a,&b);
    			ans += a*b;
    		}
    		printf("%d\n",ans);
    	}
    	return 0;
    } 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    Text Reverse HDU - 1062

    • 下面给出另一个超时程序,但是我没发现问题,大家可以找找
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    using namespace std;
    const int N=1e6+10, INF=0x3f3f3f3f;
    char a[N];
    
    int main() {
    //    freopen("data.in", "r", stdin);
    	int n; scanf("%d\n", &n);
    	for(int i=1; i<=n; i++) {
    		stack<char> sta;
    		while(1) {
    			char ch=getchar();
    			if(ch==' ') {
    				while(!sta.empty()) {
    					printf("%c", sta.top()); sta.pop();
    				}
    				printf(" ");
    			} else if(ch=='\n') {
    				while(!sta.empty()) {
    					printf("%c", sta.top()); sta.pop();
    				}
    				printf("\n"); break;
    			} else sta.push(ch);
    		}
    	}
    	return 0;
    }
    
    int main_Time_LE() {
    //	freopen("data.in", "r", stdin);
    	int n;scanf("%d\n", &n);
    	for(int i=1; i<=n; i++) {
    		while(1){
    		    memset(a, 0, sizeof(a));
                scanf("%s", a);
                int len = strlen(a);
    		    reverse(a, a+len);
                char ch=getchar();
                if(ch=='\n') break;
                printf("%s ", a);
            }
            puts(a);
    	}
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53

    Download Manager HDU - 3233

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<vector>
    #include<stack>
    #include<queue>
    #include<set>
    #include<map>
    using namespace std;
    typedef long long ll;
    const int N=1e6+10, INF=0x3f3f3f3f;
    
    int main(){
    //    freopen("data.in", "r", stdin);
        int t,n,b,cnt=0;
        while(~scanf("%d%d%d", &t,&n,&b) && t&&n&&b){
            double s,p, sum=0;
            for(int i=1; i<=t; i++){
                scanf("%lf%lf", &s, &p);
                sum += s*(100-p)*0.01;
            }
            double ans=sum/b;
            printf("Case %d: %.2lf\n\n",++cnt,ans);
        }
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    看病要排队 HDU - 1873

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    using namespace std;
    const int N=2e4+10, INF=0x3f3f3f3f;
    struct T{
        int no, id;
        T(){}
        T(int a,int b):no(a), id(b){}
        bool operator< (const T& t) const{
            if(no!=t.no) return no < t.no;
            return id > t.id;
        }
    };
    int main() {
    //	freopen("data.in", "r", stdin);
        string op; int n, a,b,cnt=0;
        while(cin>>n){
            priority_queue<T> que[4];
    	    cnt=0;
            for(int i=1; i<=n; i++){
    	        cin>>op;
    	        if(op=="IN"){
    	            cin>>a>>b;
    	            que[a].push(T(b, ++cnt));
                }else if(op=="OUT"){
                    cin>>a;
                    if(que[a].empty()) {
                        cout<<"EMPTY"<<endl;
                    }else{
                        cout<<que[a].top().id<<endl; que[a].pop();
                    }
                }
            }
        } 
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43

    Red and Black HDU - 1312

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    using namespace std;
    const int N=110, INF=0x3f3f3f3f;
    int n,m,dis[][2]={-1,0, 0,-1, 1,0, 0,1}, vis[N][N];
    char a[N][N];
    void pr(){
        for(int i=0; i<m; i++) {
            for(int j=0; j<n; j++) printf("%d ", vis[i][j]); 
            puts("");
        }
    }
    int bfs(int x,int y){
        int ans=1;
        memset(vis, 0x00, sizeof(vis));
        queue<pair<int,int> > que; que.push(make_pair(x,y)); vis[x][y]=1;
        while(!que.empty()){
            pair<int,int> p=que.front(); que.pop();
            for(int i=0; i<4; i++){
                int tx = p.first+dis[i][0];
                int ty = p.second+dis[i][1];
                if(a[tx][ty]!='.' || vis[tx][ty] || tx<0||tx>=m || ty<0||ty>=n) continue;
                ans++, vis[tx][ty]=vis[p.first][p.second]+1;
                que.push(make_pair(tx, ty));
            }
        }
        return ans;
    }
    int main() {
    //	freopen("1.cpp", "r", stdin);
    	while(~scanf("%d%d", &n,&m) && n && m){
    	    for(int i=0; i<m; i++) scanf("%s", a[i]);
            for(int i=0; i<m; i++){
                for(int j=0; j<n; j++){
                    if(a[i][j]=='@') {
                        printf("%d\n", bfs(i,j)); break;
                    }
                }
            }
    //        pr();
        }
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    最短路 HDU - 2544

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<string>
    #include<cstring>
    #include<algorithm>
    #include<stack>
    #include<queue>
    #include<vector>
    using namespace std;
    const int N=1e5+10, INF=0x3f3f3f3f;
    int head[N],cnt,dis[N],vis[N],n,m;
    struct T{
        int to,w,next;
        T(){}
        T(int a,int b):to(a), w(b){}
        bool operator<(const T &t) const{
            return w > t.w;
        }
    }G[N];
    void add(int u,int v,int w){
        G[++cnt].to = v;
        G[cnt].w = w;
        G[cnt].next = head[u];
        head[u] = cnt;
    }
    void pri_dijkstra(int s){
        memset(vis, 0x00, sizeof(vis));
        memset(dis, 0x3f, sizeof(dis));
        dis[s]=0;
        priority_queue<T> que; que.push(T(s, dis[s]));
        while(!que.empty()){
            int u=que.top().to; que.pop();
            if(vis[u]) continue;
            vis[u]=1;
            for(int i=head[u]; ~i; i=G[i].next){
                int v=G[i].to, w=G[i].w;
                if(dis[v] > dis[u]+w){
                    dis[v] = dis[u]+w;
                    que.push(T(v, dis[v]));
                }
            }
        }
    }
    int main() {
    //    freopen("1.cpp", "r", stdin);
        int a,b,c;
        while(~scanf("%d%d", &n, &m) && n && m){
            memset(head, -1, sizeof(head));
            for(int i=1; i<=m; i++){
                scanf("%d%d%d", &a,&b,&c);
                add(a, b, c), add(b, a, c);
            }
            pri_dijkstra(1);
            printf("%d\n", dis[n]);
        }
        return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
  • 相关阅读:
    [Windows 10]Qt5.14.2下安卓开发环境配置
    lua整合redis
    JAVA学习实战 reactor线程模型
    【mockserver】linux服务器搭建 easy-mock,用于挡板或模拟接口返回服务器
    Oracle创建dblink
    解决 Vue3 + Element Plus 树形表格全选多选以及子节点勾选的问题
    【C/PTA】数组进阶练习(二)
    HCIA-R&S自用笔记(24)ACL
    MyBatis拦截器(JDBC的执行流程、MyBatis执行流程、Mybatis拦截器)
    :focus伪类选择器
  • 原文地址:https://blog.csdn.net/weixin_44505194/article/details/125319967