Prime Time

Prime Time链接

Euler is a well-known matematician, and, among many other things, he discovered that the formula
n
2 + n + 41 produces a prime for 0 ≤ n < 40. For n = 40, the formula produces 1681, which is 41 ∗ 41.
Even though this formula doesn’t always produce a prime, it still produces a lot of primes. It’s known
that for n ≤ 10000000, there are 47,5% of primes produced by the formula!
So, you’ll write a program that will output how many primes does the formula output for a certain
interval.
Input
Each line of input will be given two positive integer a and b such that 0 ≤ a ≤ b ≤ 10000. You must
read until the end of the file.
Output
For each pair a, b read, you must output the percentage of prime numbers produced by the formula in
this interval (a ≤ n ≤ b) rounded to two decimal digits.
Sample Input
0 39
0 40
39 40
Sample Output
100.00
97.56
50.00

大意

根据nn+n+41,来判断在一个范围内素数所占的比例,再100。注意精度,四舍五入。

#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int s[10011];
int prime(int l)
{
	int j;
	for(j=2;j<=(int)sqrt(l);j++)
	{
		if(l%j==0)
		return 0;
	}
	return 1;
}
void db()
{
	long long l,i,j;s[0]=1;
	for(int i=1;i<10011;i++)
	{
		l=i*i+i+41;
		if(prime(l))
		s[i]=s[i-1]+1;
		else
		s[i]=s[i-1];
	}
}
int main()
{
	int a,b,k;
	db();
	while(scanf("%d%d",&a,&b)!=EOF)
	{

		k=s[b]-s[a]+prime(a*a+a+41);
		double h=k*1.0/(b-a+1)*100;
		printf("%.2lf\n",h+1e-8);
	}
	return 0;
}
### Synopsys PrimeTime 使用指南 #### 工具概述 PrimeTime 是由 Synopsys 提供的一款静态时序分析 (STA) 工具,广泛应用于数字 IC 设计领域。它能够帮助工程师评估电路的性能并确保其满足指定的时间约束条件[^1]。 #### 下载与安装 对于希望获取 PrimeTime 的用户而言,可以访问开源文档教程仓库中的链接来下载对应的用户手册。具体来说,该资源提供了版本号为 B-2008.12 的《PrimeTime PX 用户指南》PDF 文件。通过此文件可详细了解如何配置环境变量、执行基本命令以及解读报告等内容。 另外,在正式操作之前,请参照另一份关于 Synopsys EDA Tools 的安装指导完成必要的前期准备工作。这份资料特别针对 Ubuntu 16.04 LTS 平台进行了说明,并涵盖了多个重要组件如 VCS、Verdi 和 Design Compiler 等在内的部署过程描述[^3]。 #### 常见错误及其解决方案 当尝试启动 License Manager Guard (`lmgrd`) 进程时如果遇到无法创建 `/usr/tmp/.flexlm` 目录的情况,则可能是因为权限不足或者目标路径不存在所引起的问题[^2]。对此有如下几种处理方式: 1. **确认目录存在与否** 首先检查上述提到的目标位置是否存在;如果不存则手动建立相应结构。 2. **调整访问控制列表(ACLs)** 如果确定是由于缺乏适当授权而导致失败的话,则需赋予当前运行账户足够的权利去写入数据到指定区域。可以通过修改 ACL 设置实现这一目的: ```bash chmod u+w /usr/tmp/ ``` 3. **重新定义临时存储空间** 作为替代方案之一还可以考虑更改默认使用的暂存区至其他具备合适属性的地方。这通常涉及编辑 license server configuration file 中的相关条目以指向新的本地子文件夹实例。 ```ini TEMP_DIR=/home/user/license_temp_dir ``` 以上方法均有助于克服 lmgrd 创建工作所需中间节点过程中遭遇阻碍的现象。 #### 示例代码片段展示 下面给出一段简单的 Shell 脚本用于初始化 PrimeTime 所依赖的一些基础参数设置例子: ```sh #!/bin/bash # Set environment variables for PrimeTime usage. export SYNOPSYS_HOME="/path/to/synopsys/tools" export PATH=$SYNOPSYS_HOME/primetime/bin:$PATH # Launch the tool with specified project settings. pt_shell -f my_project_setup.tcl ``` 这段脚本展示了怎样设定 SYNOPSYS_HOME 变量并将 PrimeTime 的二进制目录加入系统的搜索路径当中以便于后续调用 pt_shell 启动器加载特定项目的 Tcl 脚本文件。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值