第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在代碼庫(kù)上得到錯(cuò)誤的答案。但我的數(shù)學(xué)是正確的

在代碼庫(kù)上得到錯(cuò)誤的答案。但我的數(shù)學(xué)是正確的

桃花長(zhǎng)相依 2022-08-17 10:06:39
問(wèn)題 https://www.codechef.com/problems/MATPH 的鏈接 所以,我在這個(gè)問(wèn)題上停留了幾個(gè)小時(shí),我不知道我錯(cuò)在哪里。我使用Eratosthenes的Sieve來(lái)查找素?cái)?shù),并將所有素?cái)?shù)保存在哈希映射中。在線法官在測(cè)試用例上給了我錯(cuò)誤的答案。        static void dri(int n) {            long large=0;int r=0,x,count=0,p,count1=0;            x=(int)Math.sqrt(n);            //To understand why I calculated x let's take an example            //let n=530 sqrt(530) is 23 so for all the numbers greater than 23 when             //we square them they will come out to be greater than n             //so now I just have to check the numbers till x because numbers             //greater than x will defiantly fail.I think you get             //what I'm trying to explain            while(r<x) {                r = map.get(++count); // Prime numbers will be fetched from map and stored in r                int exp = (int) (Math.log(n) / Math.log(r));                //To explain this line let n=64 and r=3.Now, exp will be equal to 3                //This result implies that  for r=3 the 3^exp is the //maximum(less than n) value  which I can calculate by having a prime in a power                if (exp != 1) {   //This is just to resolve an error dont mind this line                    if (map.containsValue(exp) == false) {                    //This line implies that when exp is not prime                      //So as I need prime number  next lines of code will calculate the nearest prime to exp                        count1 = exp;                        while (!map.containsValue(--count1)) ;                          exp = count1;                    }                    int temp = (int) Math.pow(r, exp);                    if (large < temp)                        large = temp;                }            }            System.out.println(large);        }
查看完整描述

1 回答

?
慕慕森

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個(gè)贊

對(duì)于每個(gè)測(cè)試用例,在包含最大漂亮數(shù)字的一行中輸出≤ N。如果不存在這樣的數(shù)字,則打印 ?1。

我相信4是最小的美麗數(shù),因?yàn)?是最小的素?cái)?shù),2^ 2等于4。N 只需要≥ 0。所以, ,并且應(yīng)該全部打印。我試過(guò)了。他們沒(méi)有。我相信這就是你在CodeChef上失敗的原因。dri(0)dri(1)dri(2)dri(3)?1

我把它留給你自己來(lái)了解提到的對(duì)你的方法的調(diào)用是如何表現(xiàn)的,以及如何處理它。

順便說(shuō)一句,將素?cái)?shù)保存在地圖中有什么意義?列表或排序集不是更合適嗎?


查看完整回答
反對(duì) 回復(fù) 2022-08-17
  • 1 回答
  • 0 關(guān)注
  • 126 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)