You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to FIT Cafeteria
Dear All
I am going to solve this question : 10784 - Diagonal but I faced with
this message from UVa.
"
Your submission with number 8031141 for the problem 10784 - Diagonal
has failed with verdict Time limit exceeded.
Your program used more CPU time than what is allowed for this problem.
That means that your algorithm is not fast enough or that it entered
into an infinite loop."
It is my program:
Is it slowly?
#include<iostream>
using namespace std;
int main()
{
long long int a;
int j=1;
while(cin>>a)
{
int i=3;
long long int result=0;
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to FIT Cafeteria
Did you mean while(a<result) instead of while(a>result)? I sense an
infinite loop there otherwise.
J
bahador saket
unread,
Jun 14, 2010, 7:02:09 AM6/14/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fit-ca...@googlegroups.com
Dear Josiah
I think it is correct because basic Formula: Number of diagonal in i-gon is (i * (i-3) ) / 2.
so the result is number of diagonals. attend to this trace: i is the sides / result is diagonals/ a is the input
i | a | result ------|-----|----------
3 | 11 | 3 a>result 4 | 11 | 2 a>result 5 | 11 | 5 a>result 6 | 11 | 9 a>result 7 | 11 | 14 a<result // and 7 is the correct answer
I will be happy if other can participate in this issue.