GVKun编程网logo

FilledCurve(Wolfram Mathematica)中的多余线条

30

对于想了解FilledCurve的读者,本文将是一篇不可错过的文章,我们将详细介绍WolframMathematica中的多余线条,并且为您提供关于ACM-ICPC2018焦作网络赛Mathemati

对于想了解FilledCurve的读者,本文将是一篇不可错过的文章,我们将详细介绍Wolfram Mathematica中的多余线条,并且为您提供关于ACM-ICPC2018 焦作网络赛 Mathematical Curse(dp)、EntityFramework 异常 The specified cast from a materialized ''System.Double'' type to the ''...、icpc2018 焦作 Mathematical Curse(动态规划)、Mathematica和Wolfram语言面向数学的入门指南:分数和小数的有价值信息。

本文目录一览:

FilledCurve(Wolfram Mathematica)中的多余线条

FilledCurve(Wolfram Mathematica)中的多余线条

WM中似乎有一些袋子。 我只是通过从线“手动”创建所需的曲线来解决问题。 最终代码(有一些小的改进)如下:

px = 0.7; py = 0.14; mpx = -0.3;
pts = {{-px,py},{mpx,0},{-px,-py}};
curpts = Table[f[t],{t,1,0.02}];
f = BSplineFunction[pts];
linpts = {{-px,-py},{0,py}};
allpts = Join[curpts,{linpts[[-2]],linpts[[-1]]}];
ah = Graphics[{FilledCurve[Line[allpts]],Line[linpts]}]

Result:

ACM-ICPC2018 焦作网络赛 Mathematical Curse(dp)

ACM-ICPC2018 焦作网络赛 Mathematical Curse(dp)

Mathematical Curse

  • 22.25%
  •  1000ms
  •  65536K
 

A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled in some mathematical curses. He studied hard until he reached adulthood and decided to use his knowledge to escape the castle.

There are NN rooms from the place where he was imprisoned to the exit of the castle. In the i^{th}ith room, there is a wizard who has a resentment value of a[i]a[i]. The prince has MM curses, the j^{th}jth curse is f[j]f[j], and f[j]f[j] represents one of the four arithmetic operations, namely addition(''+''), subtraction(''-''), multiplication(''*''), and integer division(''/''). The prince''s initial resentment value is KK. Entering a room and fighting with the wizard will eliminate a curse, but the prince''s resentment value will become the result of the arithmetic operation f[j]f[j] with the wizard''s resentment value. That is, if the prince eliminates the j^{th}jth curse in the i^{th}ith room, then his resentment value will change from xx to (x\ f[j]\ a[i]x f[j] a[i]), for example, when x=1, a[i]=2, f[j]=x=1,a[i]=2,f[j]=''+'', then xx will become 1+2=31+2=3.

Before the prince escapes from the castle, he must eliminate all the curses. He must go from a[1]a[1] to a[N]a[N] in order and cannot turn back. He must also eliminate the f[1]f[1] to f[M]f[M] curses in order(It is guaranteed that N\ge MNM). What is the maximum resentment value that the prince may have when he leaves the castle?

Input

The first line contains an integer T(1 \le T \le 1000)T(1T1000), which is the number of test cases.

For each test case, the first line contains three non-zero integers: N(1 \le N \le 1000), M(1 \le M \le 5)N(1N1000),M(1M5) and K(-1000 \le K \le 1000K(1000K1000), the second line contains NN non-zero integers: a[1], a[2], ..., a[N](-1000 \le a[i] \le 1000)a[1],a[2],...,a[N](1000a[i]1000), and the third line contains MM characters: f[1], f[2], ..., f[M](f[j] =f[1],f[2],...,f[M](f[j]=''+'',''-'',''*'',''/'', with no spaces in between.

Output

For each test case, output one line containing a single integer.

样例输入复制

3
2 1 5
2 3
/
3 2 1
1 2 3
++
4 4 5
1 2 3 4
+-*/

样例输出复制

2
6
3

题目来源

ACM-ICPC 2018 焦作赛区网络预赛

 

 

 

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int kMaxN = 1005;
const int kMaxM = 6;

long long f[kMaxN][kMaxM];
long long g[kMaxN][kMaxM];
int a[kMaxN];
char curse[kMaxM];

int main() {
  int T;
  scanf("%d", &T);
  for (int cas = 1; cas <= T; ++cas) {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    memset(f, 0xa0, sizeof(f));
    memset(g, 0x70, sizeof(g));
    for (int i = 0; i <= n; ++i) {
      f[i][0] = k;
      g[i][0] = k;
    }
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
    }
    scanf("%s", curse);
    for (int j = 1; j <= m; ++j) {
      for (int i = j; i <= n; ++i) {
        f[i][j] = f[i - 1][j];
        g[i][j] = g[i - 1][j];
        if (curse[j - 1] == ''+'') {
          f[i][j] = max(f[i][j], f[i - 1][j - 1] + a[i]);
          g[i][j] = min(g[i][j], g[i - 1][j - 1] + a[i]);
        } else if (curse[j - 1] == ''-'') {
          f[i][j] = max(f[i][j], f[i - 1][j - 1] - a[i]);
          g[i][j] = min(g[i][j], g[i - 1][j - 1] - a[i]);
        } else if (curse[j - 1] == ''*'') {
          f[i][j] = max(f[i][j], f[i - 1][j - 1] * a[i]);
          f[i][j] = max(f[i][j], g[i - 1][j - 1] * a[i]);
          g[i][j] = min(g[i][j], f[i - 1][j - 1] * a[i]);
          g[i][j] = min(g[i][j], g[i - 1][j - 1] * a[i]);
        } else if (curse[j - 1] == ''/'') {
          f[i][j] = max(f[i][j], f[i - 1][j - 1] / a[i]);
          f[i][j] = max(f[i][j], g[i - 1][j - 1] / a[i]);
          g[i][j] = min(g[i][j], f[i - 1][j - 1] / a[i]);
          g[i][j] = min(g[i][j], g[i - 1][j - 1] / a[i]);
        }
        //printf("[%d][%d] = %lld %lld\n", i, j, f[i][j], g[i][j]);
      }
    }
    printf("%lld\n", f[n][m]);
  }
  return 0;
}

 

EntityFramework 异常 The specified cast from a materialized ''System.Double'' type to the ''...

EntityFramework 异常 The specified cast from a materialized ''System.Double'' type to the ''...

实体类:

    public class ReportEntity
    {
        public string FactorName { get; set; }
        public double MaxVal { get; set; }
        public double MinVal { get; set; }
        public double AvgVal { get; set; }
        public string UpdateTime { get; set; }
        public string Unit { get; set; }
        public int DecimalDigit { get; set; }
    }

SQL 语句

            string sqlstr = "   select b.FactorName,cast(MAX(a.Val) as float) as MaxVal,cast(MIN(a.Val) as float) as MinVal,cast(AVG(a.Val) as float) as AvgVal,"
                            + strTime + " as UpdateTime,b.Unit,b.DecimalDigit "
                            + "    from Instrument_Data a,Factor b   "
                            + " where a.UpdateTime between ''" + dtBegin + "'' and ''" + dtEnd + "''    "
                            + " and a.FactorID = b.FactorID   "
                            + " group by b.FactorName,b.Unit, " + strTime + ",b.DecimalDigit  "
                            + " order by b.FactorName,b.Unit," + strTime + ",b.DecimalDigit  ";

            using (var db = new DAL.WSIPCContext())
            {
                var result3 = db.Database.SqlQuery<Entity.ReportEntity>(sqlstr);
                this.lsvData.Items.Clear();
                foreach (Entity.ReportEntity i in result3)
                {
                    ListViewItem item = new ListViewItem();
                    item.SubItems.Clear();
                    item.Text = i.UpdateTime;
                    item.SubItems.Add(i.FactorName);
                    string format = "#0.".PadRight(i.DecimalDigit + 3, ''0'');
                    item.SubItems.Add(i.MaxVal.TryToDoubleStr(format));
                    item.SubItems.Add(i.MinVal.TryToDoubleStr(format));
                    item.SubItems.Add(i.AvgVal.TryToDoubleStr(format));
                    item.SubItems.Add(i.Unit);
                    this.lsvData.Items.Add(item);
                }
            }

将 double 换成 float 出现错误。EF 使用 System.Double 对应 SQLServer 中的 float。

重点关注:此处对 SQL 语句的结果也有要求,结果必须转换为 float,才能与实体类映射成功!

icpc2018 焦作 Mathematical Curse(动态规划)

icpc2018 焦作 Mathematical Curse(动态规划)

传送门

ac 代码:

#include<bits/stdc++.h>
#define per(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
//#define int long long
const ll inf =2333333333333333LL;
const double eps=1e-8;
int read(){
    char ch=getchar();
    int res=0,f=0;
    while(ch<''0'' || ch>''9''){f=(ch==''-''?-1:1);ch=getchar();}
    while(ch>=''0''&&ch<=''9''){res=res*10+(ch-''0'');ch=getchar();}
    return res*f;
}
// ------------------------head
#define mod 1000000009
const int siz=10005;
ll dp[1005][6],k;
int T,n,m,a[1005];
char ch[6];
ll fun(int rhs,ll d,char op){
    if(op==''+'')return d+(ll)rhs;
    else if(op==''-'')return d-(ll)rhs;
    else if(op==''*'')return d*(ll)rhs;
    else if(op==''/'')return d/(ll)rhs; 
}

signed main()
{
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%lld",&n,&m,&k);
        ll ans=-inf;
        per(i,1,n)scanf("%d",&a[i]);
        per(i,1,m)cin>>ch[i];
        ll _mi[1005][6];
        per(i,0,n)dp[i][0]=_mi[i][0]=k;
        per(i,1,m){per(j,0,n)_mi[j][i]=inf;per(j,0,n)dp[j][i]=-inf;}
        per(i,1,n){
            dp[i][1]=max(dp[i-1][1],fun(a[i],k,ch[1]));
            _mi[i][1]=min(_mi[i-1][1],fun(a[i],k,ch[1]));
        }
        per(i,2,m){//区分正数和负数
            per(j,i,n){
                if(a[j]<0&&(ch[i]==''*''||ch[i]==''/'')){
                    dp[j][i]=max(dp[j-1][i],fun(a[j],_mi[j-1][i-1],ch[i]));
                    _mi[j][i]=min(_mi[j-1][i],fun(a[j],dp[j-1][i-1],ch[i]));
                }
                else {
                    ll ma=dp[j-1][i-1];
                    dp[j][i]=max(dp[j-1][i],fun(a[j],dp[j-1][i-1],ch[i]));
                    _mi[j][i]=min(_mi[j-1][i],fun(a[j],_mi[j-1][i-1],ch[i]));
                }
            }
        }
        if(m==1){
            ll res=-inf;
            per(i,1,n)res=max(res,dp[i][1]);
            printf("%lld\n",res);
        }
        else printf("%lld\n",dp[n][m]);
    }
    return 0;
}

 

Mathematica和Wolfram语言面向数学的入门指南:分数和小数

Mathematica和Wolfram语言面向数学的入门指南:分数和小数

Mathematica在其三十年的开发历程中,在技术计算领域确立了最先进的技术,并为全球技术创新人员、教育工作者、学生和其他人士提供了最主要的计算环境。

免费试用mathematica chinese12.3.1

mathematica教程,mathematica下载,mathematica购买,科技计算软件

在 Wolfram 语言中,精确输入(如分数)会提供精确的输出:

(用 CTRL+ / 输入分数.)

Mathematica教程

用 Together 写成最小公分母的形式:
Mathematica教程

有些数字表示成 ScientificForm 形式会更合适:

Mathematica教程

在适合的情况下,系统自动使用 ScientificForm 形式:
Mathematica教程

免费试用mathematica chinese12.3.1


Mathematica以卓越的技术和简便的使用方法享誉全球,在此基础上,它提供了单个集成并且持续扩展的系统,涵盖了最广最深的技术计算功能,并可通过网页浏览器实现云端的完美访问,以及在所有现代桌面系统上的本地访问。

如果想了解更多关于Mathematica的功能及试用问题,联系在线客服

关于FilledCurveWolfram Mathematica中的多余线条的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于ACM-ICPC2018 焦作网络赛 Mathematical Curse(dp)、EntityFramework 异常 The specified cast from a materialized ''System.Double'' type to the ''...、icpc2018 焦作 Mathematical Curse(动态规划)、Mathematica和Wolfram语言面向数学的入门指南:分数和小数的相关知识,请在本站寻找。

本文标签: