网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
06月28日漏签0天
acm吧 关注:26,555贴子:48,338
  • 看贴

  • 图片

  • 吧主推荐

  • 游戏

  • 1回复贴,共1页
<<返回acm吧
>0< 加载中...

超时了,哪个大神帮我改一下

  • 只看楼主
  • 收藏

  • 回复
  • adm2501
  • 路人甲
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
A - Problem_ATime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status
Description
All you know Goldbach conjecture.That is to say, Every even integer greater than 2 can be expressed as the sum of two primes. Today, skywind present a new conjecture: every even integer can be expressed as the difference of two primes. To validate this conjecture, you are asked to write a program.
Input
The first line of input is a number nidentified the count of test cases(n<10^5). There is a even number xat the next nlines. The absolute value of xis not greater than 10^6.
Output
For each number xtested, outputstwo primes aand bat one line separatedwith one space where a-b=x. If more than one group can meet it, output the minimum group. If no primes can satisfy it, output *FAIL*.
Sample Input
361020
Sample Output
11 513 323 3


  • adm2501
  • 路人甲
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include<stdio.h>
int prime(int n);
int main()
{
int n;
scanf("%d",&n);
while (n--)
{
int a, b, i;
scanf("%d", &a);
if (a<=2||a%2!=0)
{
printf("FAIL"); continue;
}
for (i = 2; i < a; i++)
{
if (prime(i))
{
b = a + i;
if (prime(b))
{
printf("%d", b);
printf(" ");
printf("%d", i); break;
}
else
{
continue;
}
}
}
if (prime(b)==0 || prime(i)==0)
{
printf("FAIL");
}
}
return 0;
}
int prime(int n)
{
int i;
i = 2;
while (i<n)
{
if (n%i == 0)
break;
i++;
}
if (i == n)
return 1;
else
return 0;
}


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 1回复贴,共1页
<<返回acm吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示