http://acm.hnu.cn/online/?action=problem&type=show&id=12817&courseid=267 7.19hnu/数据结构/数学 xxs.code

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<iostream>
 4 #include<algorithm>
 5 #include<deque>
 6 #include<cstdlib>
 7 using namespace std;
 8 typedef long long INT;
 9 const INT MOD = 1000000007;
10 const int maxn = 2000000+5;
11 char str[maxn],temp[maxn];
12 int get_num(INT s,INT t)
13 {
14     for(int i = 0;i < t;++i)
15     {
16         s = s >> 1;
17         if(s == 0)
18         return 0;
19     }
20     return s;
21 }
22 int main()
23 {
24     while(gets(temp))
25     {
26         if(temp[0] == ‘#‘)
27         break;
28         int len = strlen(temp),f = 0;
29         for(int i = 0;i < len; ++i)
30         if(temp[i] != ‘ ‘)
31         str[f++] = temp[i];
32         str[f] = NULL;
33         len = f;
34         deque<INT> que1;
35         deque<char> que2;
36         //预处理
37         for(int i = 0;i < len-2;++i)
38         if(str[i] == ‘>‘ && str[i+1] == ‘>‘ && str[i+2] != ‘>‘)
39         str[i] = str[i+1] = ‘^‘;
40         char ss[20];       //缓存数字
41         for(int i = 0;i < len;++i)
42         {
43             if(str[i] == ‘S‘  || str[i] == ‘s‘)
44             {
45                 i++;
46                 que2.push_front(‘<‘);
47             }
48             if(str[i] == ‘>‘)
49             {
50                 INT tt = *que1.begin();
51                 que1.pop_front();
52                 que2.pop_front();    //计算完后把‘<‘弹出来
53                 tt *= tt;
54                 tt %= MOD;
55                 if(*que2.begin() == ‘^‘)
56                 {
57                     INT tt2 = *que1.begin();
58                     que1.pop_front();
59                     que1.push_front(get_num(tt2,tt));
60                     que2.pop_front();
61                 }
62                 else que1.push_front(tt);
63             }
64             if(str[i] == ‘^‘)
65             {
66                 i++;
67                 que2.push_front(‘^‘);
68             }
69             if(str[i] >= ‘0‘ && str[i] <= ‘9‘)
70             {
71                 int ll = 0;
72                 while(str[i] >= ‘0‘ && str[i] <= ‘9‘)
73                 {
74                     ss[ll++] = str[i];
75                     i++;
76                 }
77                 i--;
78                 ss[ll] = NULL;
79                 int tt = atoi(ss);
80                 if(*que2.begin() == ‘^‘)
81                 {
82                     int tt2 = *que1.begin();
83                     que1.pop_front();
84                     que2.pop_front();
85                     que1.push_front(get_num(tt2,tt));  //get_num计算tt2 >> tt之后压回到栈中
86                 }
87                 else que1.push_front(tt);
88             }
89         }
90
91         printf("%d\n",*que1.begin());
92         que2.clear();
93         que1.clear();
94     }
95     return 0;
96 }

http://acm.hnu.cn/online/?action=problem&type=show&id=12817&courseid=267 7.19hnu/数据结构/数学 xxs.code

时间: 2024-11-11 03:04:44

http://acm.hnu.cn/online/?action=problem&type=show&id=12817&courseid=267 7.19hnu/数据结构/数学 xxs.code的相关文章

MVC路由规则以及前后台获取Action、Controller、ID名方法

1.前后台获取Action.Controller.ID名方法 前台页面:ViewContext.RouteData.Values["Action"].ToString(); ViewContext.RouteData.Values["Controller"].ToString(); ViewContext.RouteData.Values["ID"].ToString(); 后台页面:RouteData.GetRequiredString(&qu

MVC前后台获取Action、Controller、ID名方法 以及 路由规则

前后台获取Action.Controller.ID名方法 前台页面:ViewContext.RouteData.Values["Action"].ToString();//获取Action名称   ViewContext.RouteData.Values["Controller"].ToString();//获取控制器名称          ViewContext.RouteData.Values["ID"].ToString();//获取路由参

kafka javax.management.InstanceAlreadyExistsException: kafka.consumer:type=app-info,id=consumer-1

错误日志: 2019-10-11 17:50:48.744 WARN []-[o.a.k.clients.consumer.ConsumerConfig :173] The configuration num.replica.fetchers = 1 was supplied but isn't a known config.2019-10-11 17:50:48.747 INFO []-[o.a.kafka.common.utils.AppInfoParser :82] Kafka versi

No result defined for action cn.crm.action.LinkManAction and result input

这是struts2的一个拦截器报的错误,当你的form中的数据有问题,比如说<input type="text" name="receiverLoginID" value="<%=name%>"/>当 name值为NULL时,就出这个错了,所以你可以在当前页面加入以下标签<div style="color:red">    <s:fielderror /></div>

杭电 HDU ACM 1898 Sempr == The Best Problem Solver?

Sempr == The Best Problem Solver? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 1438    Accepted Submission(s): 940 Problem Description As is known to all, Sempr(Liangjing Wang) had solved mo

HNU 13108-Just Another Knapsack Problem (ac自动机上的dp)

题意: 给你一个母串,多个模式串及其价值,求用模式串拼接成母串(不重叠不遗漏),能获得的最大价值. 分析: ac自动机中,在字典树上查找时,用dp,dp[i]拼成母串以i为结尾的子串,获得的最大价值,dp[i]=max(dp[i],dp[i-len]+val[tmp]).,len是模式串的长度,val[tmp]为其价值. #include <cstdio> #include <cstring> #include <cmath> #include <queue>

HDU ACM 2740 Root of the Problem 简单数学题

题意:求A,使得A^N最接近B. 分析:A=B^(1/n),对其上下取整,在各取N次幂,取最接近B的. #include<iostream> #include<cmath> using namespace std; int main() { int B,N,p,q; double tmp; while(cin>>B>>N && (B||N)) { tmp=pow(1.0*B,1.0/N); p=floor(tmp); //向下取整 q=cei

druid抛出异常:javax.management.InstanceAlreadyExistsException: com.alibaba.druid:type=DruidDataSource,id=xxx

参考: https://www.cnblogs.com/youzhibing/p/6826767.html 结论: 问题产生的根本原因还真是:同一实例被启动了两遍,Path为/SLBAdmin启动一次,Path为/wgp-Web启动一次, 开发过程中最好保证工程名与发布路径保证一直,避免不必要的麻烦 原文地址:https://www.cnblogs.com/moly/p/8308871.html

【AC自动机+DP】HNU 13108 Just Another Knapsack Problem

通道:http://acm.hnu.cn/online/?action=problem&type=show&id=13108&courseid=296 题意:N个匹配串及权值,求完全匹配模式串的最大值. 思路:建AC自动机,dp[i]到达i的最大值,dp[i]=max(dp[i-L]+W); 代码:https://github.com/Mithril0rd/Rojo/blob/master/hnu13108.cpp