15,890,741 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Jahirul Sarker (Top 37 by date)
Jahirul Sarker
9-Feb-23 20:38pm
View
I edited in "What have you tried" section.
Jahirul Sarker
9-Feb-23 19:48pm
View
Thank you. But still TLE.
Last submitted solution:
```
//package pac1;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int k = sc.nextInt();
int sum=0;
int top = (int)Math.sqrt(n);
for(int i=1; i<=top; i++) {
if(n%i==0 ){
if(i%k!=0)sum+=i;
if((n/i)%k!=0)sum+=(n/i);
}
}
System.out.println(sum);
}
}
}
```
Jahirul Sarker
9-Feb-23 5:13am
View
I searched in Google for the solution of this problem in Java, but found no results. A user asked on this same issue in UVA discussion site.. but no reply has been given.
I don't know how to solve this problem by maintaining a list of prime numbers.
Jahirul Sarker
9-Feb-23 4:40am
View
"your optimized solution is flawed: it adds twice to the sum the square root of N." I edited the mistake.
I submitted your solution. But still getting TLE. @CPallini
Jahirul Sarker
3-Jan-23 11:52am
View
It worked. I was really worried and kept submitting with little little change but couldn't figure out the problem. Your solution saved me. Thank you so much.
Jahirul Sarker
3-Jan-23 10:39am
View
Removing Scanner... from main method gives "Cannot make a static reference to the non-static field sc" message.. and can't run the program in eclipse
Jahirul Sarker
3-Jan-23 7:00am
View
Hello @Richard, thanks for responding. I removed that package line and submitted, but it doesn't solve the problem.. same runtime error happens and same message.
Jahirul Sarker
11-Mar-22 6:07am
View
Deleted
I have found the solution.
1st term = max(a)/b + max(a)%b;
2nd term = max(a)/b + b - 2;
If 1st term>2nd term then answer is 1st term else 2nd term.
Thank you.
Jahirul Sarker
11-Mar-22 6:06am
View
Now I understand.
1st term = max(a)/b + max(a)%b;
2nd term = max(a)/b + b - 2;
If 1st term>2nd term then answer is 1st term else 2nd term.
Thank you.
Jahirul Sarker
11-Mar-22 5:52am
View
Between 1 and 10.. if b=3 then max(a/b) = 10/3= 3(int);
And max(a%b) = 8%3 = 2
So, max(a/b)+max(a%b) = 3+2 = 5;
But the maximum value of this function between 1 to 10 should be 4.
Jahirul Sarker
11-Mar-22 5:41am
View
Deleted
Between 1 and 10.. if b=3 then max(a/b) = 10/3= 3(int);
And max(a%b) = 8%3 = 2
So, max(a/b)+max(a%b) = 3+2 = 5;
But the maximum value of this function between 1 to 10 should be 4.
Jahirul Sarker
27-Jan-22 18:55pm
View
I will cover the topics of C from a good book(Teach yourself C) then I will start to learn C++.
Jahirul Sarker
25-Jan-22 6:15am
View
Sir, I love competitive programming. Shouldn't I go with C++?
Jahirul Sarker
24-Jan-22 3:38am
View
"It looks like "student code" - poorly indented"
I haven't read any books on C. I learned C's basic from a youtube C tutorial class.
I have no theoretical knowledge on C. But this year I admitted to a college with CSE major. I hope I will read some good books.
Jahirul Sarker
24-Jan-22 3:33am
View
"any non-zero value is true in C so there is no need to compare "virtual booleans" with "0"."
while(givenValue)? instead of while(givenValue!=0)?
Jahirul Sarker
24-Jan-22 3:29am
View
Actually, it was a brute force approach to solve a previous contest problem and all the variable name was a, b, c...... To post here I gave some name but still haven't changed anything more than that. It's a 50 lines code and took me more than half hours to implement it. So, I am looking for a shorter and less complex method to find nth palindrome.
Jahirul Sarker
16-Jan-22 21:53pm
View
It's working but I want to keep makeArray function.
Jahirul Sarker
9-Dec-21 14:16pm
View
Yes, now it's clear to me.
'0' in ASCII = 48
'1' in ASCII = 49
so, 1-0 is equivalent to 49-48.
Thank you
Jahirul Sarker
9-Dec-21 14:15pm
View
Yeah, I can understand it now.
'0' in ASCII = 48
'1' in ASCII = 49
so, 1-0 is equivalent to 49-48.
Thank you so much.
Jahirul Sarker
9-Dec-21 14:13pm
View
I can understand it now. Thank you.
Jahirul Sarker
19-Nov-21 6:56am
View
"Changing to an array won't help that: the size of an integer doesn't change no matter how many of them you allocate, and you can't read a number "across elements" of an array."
Yes, I understand it now. I should use long or long long int. After using long long int, if I want to limit the size of input values, then I can simply use "%1000lld".
"When you declare an array, the name of the array is a pointer to the first element; these two staments are equivelent"
I get it.
Yes, your answer helps me a lot.
Thank you.
Jahirul Sarker
8-Nov-21 3:29am
View
Deleted
I used 'printf("%s", str)' inside the loop and submitted to Codeforces judge. It was accepted. But it print results one by one not altogether. Should I skip 'printing-altogether' method for some time? What will be your suggestion for me?
Jahirul Sarker
8-Nov-21 3:09am
View
Deleted
Please, test the code:
for(i=0; i<n; i++){
="" alp="j=last=0;
" fgets(str,="" sizeof="" str,="" stdin);
=""
="" while(str[j]!="\0" )="" {
="" if((str[j]="">='a')&&(str[j]<='z')){
alp++;
first=str[0];
last=str[alp-1];
numint=alp;
}
j++;
}
if(numint<=10){
printf("%s", str);
}else{
printf("%c%d%c\n", first, (numint-2), last);
}
/*k[i]=first;
z[i]=last;
h[i]=numint;
t[i]=str;*/
}
/*for(i=0; i
Jahirul Sarker
8-Nov-21 2:00am
View
"The problem is that you don't save any strings"--- I am looking for a way to save all the strings but I can't find any. Please give me some hints.
Jahirul Sarker
7-Nov-21 23:46pm
View
Deleted
Inside for loop: 'printf("%s", str);' can successfully print the strings... But it prints right after it get inputs. You see in my code that I want to store the strings first and then want to print all the strings altogether.... then it shows this warning: assignment to 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion].
so, how can I do that?
Jahirul Sarker
7-Nov-21 23:22pm
View
"Some other observations:
scanf("%d\n", &n) doesn't do what you think. Try this and see what happens:
int n;
char str[100];
printf("How may strings? ");
scanf("%d\n", &n);
int i;
for(i = 0; i < n; ++i) {
printf("Enter string %d : ", i);
fgets(str, sizeof str, stdin);
}"
yes you are right.
Jahirul Sarker
7-Nov-21 23:14pm
View
"warning: assignment to 'char' from 'char *' makes integer from pointer without a cast [-Wint-conversion]|"
I use codeblocks 20.03 in windows 10
Jahirul Sarker
28-Oct-21 7:27am
View
"Undefined reference to 'closeEnough'"
"error: Id returned 1 exit status."
IDE is showing this message. I use CodeBlocks 20.03.
I added stdio library, stdlib lib, math lib... But Program doesn't run.
Jahirul Sarker
27-Oct-21 6:47am
View
Thank you. Honestly, I wasn't aware of that. I was stupid. I wasn't aware of the points.
I will never repeat this mistake again.
Jahirul Sarker
26-Oct-21 23:09pm
View
What should I do?
Jahirul Sarker
26-Oct-21 22:51pm
View
Your answer for this problem is good.. But I can't figure out the solution. I am new to programming... please help.. I am exhausted.
Jahirul Sarker
26-Oct-21 22:48pm
View
Please help me to solve it... I'am trying it for almost ten days.
Jahirul Sarker
24-Oct-21 2:31am
View
Deleted
It's hard for me. I don't understand. Can you please make it simple? I never read epsilon before. Or you can help me with some resource that will help me to understand 'closeEnough' function.
Jahirul Sarker
24-Oct-21 2:23am
View
1st two outputs are integers... But the third printf is printing float... that's why I am telling that third statement is not working.
Jahirul Sarker
21-Oct-21 9:22am
View
I changed it to for(i=0; i<=2; i=i+0.2).
But it's not working. Same problem remains. Third condition is not working
Jahirul Sarker
16-Oct-21 3:41am
View
Deleted
if(h==hour &&m== minute&& s==second){
break;
}
s++;
sleep(1);
system("cls");
But now it's working(please check.)
Thank you for your kind response.
Jahirul Sarker
30-Sep-21 3:12am
View
Thank you so much for your precious suggestion. And today I solved the issue with this program. My solution is given below.[SOLUTION-3]
Show More