Loading [MathJax]/jax/input/TeX/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >hdu 4891—水的问题 但WA非常多

hdu 4891—水的问题 但WA非常多

作者头像
全栈程序员站长
发布于 2022-07-06 12:13:36
发布于 2022-07-06 12:13:36
19700
代码可运行
举报
运行总次数:0
代码可运行

大家好,又见面了,我是全栈君

这个问题是在一个坑—-即使在使用long long 这将是超出范围

自己显得很长的时间去阅读很多次的称号仍然没想到

当时的想法是要记住—-无论如何,我用long long 已经最大范围。当然不能用更大的类型–即使unsigned它是唯一的 比long long 大一倍。如今回头看,这样的想法太唯心,不是理性分析的结果啊,,

代码:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
//1005
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;
#define ll long long
const ll lim=1e5;

int main()
{
    //freopen("hdu1005.txt","r",stdin);
    ll cnt,ans,kr,sp,n;
    char c;
    int last;
    bool flag=0;
    while(~scanf("%I64d",&n))
    {
        flag=0;
        getchar();
        cnt=kr=sp=0;
        ans=1;
        while(1)
        {
            c=getchar();
            if(c == '\n')cnt++;
            if(cnt>=n  || c==EOF)break;
            //{}
            if(c == '$')
            {
                kr=last=0;
                while(1)
                {
                    c=getchar();
                    if(c == '\n'){cnt++;if(kr)last=1;continue;}
                    if(c == ' ')kr++;
                    //if(c != ' ' && c == '\n')conti
                    if(c != ' ' && kr){if(ans>lim)flag=1;ans*=(kr+1);kr=0;}
                    if(c == '$')break;
                }
                if(c != ' ' && kr){if(ans>lim)flag=1;ans*=(kr+1);kr=0;}
                ////
            }
            if(c == '{')
            {
                sp=0;
                while(1)
                {
                    c=getchar();
                    if(c == '\n'){cnt++;}
                    if(c == '|'){sp++;}
                    if(c == '}')break;
                }
                if(ans>lim)flag=1;
                ans*=(sp+1);
                sp=0;
            }
        }
        if(ans>lim||flag)printf("doge\n");
        else  printf("%I64d\n",ans);
    }
    return 0;
}

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116711.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年1月1,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
HDU-5514-Frogs
该文是有关ACM模板题目的解题报告,题目为HDU-5514-Frogs,作者通过编写代码,分两步解决了该问题。第一步通过容斥原理求解了该问题,第二步通过欧拉函数求解了该问题。
f_zyj
2018/01/09
5830
HDU-5514-Frogs
HDU 2669 Romantic
Problem Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lovers Walk passing, and so are You. ................................Write in English class by yife
attack
2018/04/12
5770
HDU 2669 Romantic
hdu 2421 Deciphering Password(约数个数问题)
大家好,又见面了,我是全栈君。 http://acm.hdu.edu.cn/showproblem.php?pid=2421 A^B 能够写成 p1^e1 * p2^e2 * …..*pk^ek。(A
全栈程序员站长
2022/07/08
1810
HDU 2227 Find the nondecreasing subsequences(DP)
大家好,又见面了,我是全栈君。 Problem Description How many nondecreasing subsequences can you find in th
全栈程序员站长
2022/07/06
1570
HDU-4407-Sum(容斥原理)「建议收藏」
XXX is puzzled with the question below:
全栈程序员站长
2022/07/08
2050
Day4上午解题报告
预计分数:50 +0+0=50 实际分数:50+0+10=60 毒瘤出题人,T3不给暴力分 (*  ̄︿ ̄)  T1 https://www.luogu.org/problem/show?pid=T15
attack
2018/04/11
8010
Day4上午解题报告
Day4下午解题报告
预计分数:30+30+0=60 实际分数:30+30+10=70 稳有个毛线用,,又拿不出成绩来,, T1 https://www.luogu.org/problem/show?pid=T15626
attack
2018/04/11
6760
Day4下午解题报告
【HDU4947】GCD Array (莫比乌斯反演+树状数组)
BUPT2017 wintertraining(15) #5H HDU- 4947 题意 题解 官方题解: 代码 #include<cstdio> #include<cstring> #include
饶文津
2020/06/02
3210
【HDU4947】GCD Array (莫比乌斯反演+树状数组)
hdu 4507 数位dp(求和,求平方和)[通俗易懂]
大家好,又见面了,我是全栈君。 http://acm.hdu.edu.cn/showproblem.php?pid=4507 Problem Description   单身!
全栈程序员站长
2022/07/07
3890
hdu1055
#include<iostream> #include<iomanip> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<map> #include<stack> #include<set> #include<queue> #include<string> #include<vector> #define eps
@坤的
2018/06/04
4100
hdu 4661 Message Passing(木DP&amp;组合数学)
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1187 Accepted Submission(s): 423
全栈程序员站长
2022/07/06
2590
HDU3949 XOR(线性基第k小)
XOR is a kind of bit operator, we define that as follow: for two binary base number A and B, let C=A XOR B, then for each bit of C, we can get its value by check the digit of corresponding position in A and B. And for each digit, 1 XOR 1 = 0, 1 XOR 0 = 1, 0 XOR 1 = 1, 0 XOR 0 = 0. And we simply write this operator as ^, like 3 ^ 1 = 2,4 ^ 3 = 7. XOR is an amazing operator and this is a question about XOR. We can choose several numbers and do XOR operatorion to them one by one, then we get another number. For example, if we choose 2,3 and 4, we can get 2^3^4=5. Now, you are given N numbers, and you can choose some of them(even a single number) to do XOR on them, and you can get many different numbers. Now I want you tell me which number is the K-th smallest number among them.
attack
2018/08/01
3410
hdu2544_GB4278
大家好,又见面了,我是你们的朋友全栈君。 Faulty Odometer http://acm.hdu.edu.cn/showproblem.php?pid=4278 Time Limit: 2000
全栈程序员站长
2022/08/04
1790
Codeforces Round #269 (Div. 2) A B C「建议收藏」
题目链接:http://codeforces.com/problemset/problem/471/C
全栈程序员站长
2022/07/07
2190
hdu4288 Coder(段树+分离)
就是直接申明一个vector的容器。然后直接用vector里面的操作比方 insert,erase等等操作。
全栈程序员站长
2022/07/05
2340
POJ 1964&HDU 1505&HOJ 1644 City Game(最大0,1子矩阵和总结)
最大01子矩阵和,就是一个矩阵的元素不是0就是1,然后求最大的子矩阵,子矩阵里的元素都是相同的。 这个题目,三个oj有不同的要求,hoj的要求是5s,poj是3秒,hdu是1秒。不同的要求就对应不同的难度,不同的逼格。 先看最low的, HOJ 1664 5秒钟的时间,够长了。我很容易想到可以最大子矩阵和来求解,二者本来就很像,关于最大子矩阵和这个博客里有介绍 最大子矩阵和 这里我们可以把F变成1,把R变成负无穷大,这样求解最大子矩阵和就可以得到答案 #inc
ShenduCC
2018/04/26
8690
POJ 1964&HDU 1505&HOJ 1644 City Game(最大0,1子矩阵和总结)
BUPT2017 wintertraining(15) #2 题解
​ 因为2520%pre_lcm0,所以x%pre_lcm(x%2520)%pre_lcm
饶文津
2020/06/02
4510
BUPT2017 wintertraining(15) #2 题解
HDU4352 XHXJ's LIS(LIS 状压)
刚开始的思路是$f[i][j]$表示到第$i$位,LIS长度为$j$的方案。 然而发现根本不能转移,除非知道了之前的状态然后重新dp一遍。。
attack
2018/09/30
6380
单调栈总结_进栈和出栈的算法思想
单调栈是一种特殊的栈,特殊之处在于栈内的元素都保持一个单调性。 假设下图是一个栈内元素的排列情况(单调递增的栈):
全栈程序员站长
2022/11/09
3540
单调栈总结_进栈和出栈的算法思想
hdu 3642 Get The Treasury (三维的扫描线)[通俗易懂]
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/115678.html原文链接:https://javaforall.cn
全栈程序员站长
2022/07/10
2130
相关推荐
HDU-5514-Frogs
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验