Can anyone share question and if it is accepted then solution so that we all can prepare for codevita as it is practice round. your co-operation will be appreciated.
Do u want questions?
Mockvita is for your practise so that you can perform well in actual Codevita round. Try on your own now and ask this question tomorrow when it ends
Ohh, I’m not here to beg answer , i want just question . So please don’t misunderstand anyone without knowing the sole purpose .
Then ask for questions after the round ends. (Ends at 20th 9am)
This is the first mockvita going on there will be 2nd mockvita also before the zonal round starts…
Register at codevita and u will get notified for the second one
Now that contest is over, someone please share the solution of C, D, E and F problems of Mockvita-1.
Please anyone share solution of question B.
If you want solution to fibonacci problem, here it is HgL6tm - Online C++0x Compiler & Debugging Tool - Ideone.com.
THis code is giving wrong answer
#include<algorithm>
#define ll long long int
#include<cmath>
#include<map>
using namespace std;
int main()
{
ll n;
cin>>n;
map<double,ll> m;
while(n--)
{
double a,b,c;
cin>>a>>b>>c;
double dist = sqrt(a*a +b*b);
double time = dist/c;
m[time]++;
}
ll ans=0;
for(auto x:m)
{
if(x.second>=2)
ans+=(x.second*(x.second-1))/2;
}
cout<<ans<<endl;
return 0;
}
While this one is giving accepted only difference is in calculating time variable in first I used sqrt while in second I not used sqrt and try without sqrt . So it’s a problem in sqrt or anything else
please help
Here is second one which is accepted
#include<iostream>
#include<algorithm>
#define ll long long int
#include<cmath>
#include<map>
using namespace std;
int main()
{
ll n1;
cin>>n1;
ll i1=0;
map<double,ll> mt;
while(n1--)
{
double x,y,v;
cin>>x>>y>>v;
double d =(x*x +y*y);
double t = d/(v*v);
mt[t]++;
}
ll finalans=0;
for(map<double,ll>::iterator itmp=mt.begin();itmp!=mt.end();itmp++)
{
if(itmp->second>=2)
finalans+=(itmp->second*((itmp->second)-1))/2;
}
cout<<finalans;
return 0;
}
BRUTE FORCE SOLUTION
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
using namespace std;
ll maxN = 1e5;
vector primes(maxN, true);
void siieve(){
for(ll num = ll(2); numnum < maxN; num++){
if(primes[num]){
for(ll i = numnum; i < maxN; i+=num)
primes[i] = false;
}
}
}
int main(){
fastio;
primes[1] = false;
siieve();
ll n1, n2;
cin>>n1>>n2;
vector<string> filteredPrimes;
vector<ll> comb;
set<ll> lst;
for(ll i = n1; i <= n2; i++)
if(primes[i])
filteredPrimes.push_back(to_string(i));
for(ll i = ll(0); i < ll(filteredPrimes.size()); i++){
for(ll j = ll(0); j < ll(filteredPrimes.size()); j++){
if(i == j)
continue;
string tmp = filteredPrimes[i] + filteredPrimes[j];
comb.push_back(stoi(tmp));
}
}
for(ll x : comb)
if(primes[x])
lst.insert(x);
auto it = lst.end();
it--;
ll a = *(lst.begin()), b = *it, c;
for(ll i = ll(3); i <= ll(lst.size()); i++){
c = a + b;
a = b;
b = c;
}
cout<<c;
return 0;
}
This one is 4th question
And here is my code . But I don’t know where it is failing please help me . @everule1 @galencolin
@vijju123 @l_returns
#include<algorithm>
#define ll long long int
#include<cmath>
using namespace std;
int main()
{
ll n;
cin>>n;
ll t,wt;
cin>>t>>wt;
ll r;
cin>>r;
ll ans=0;
ll whole[12*31+5];
ll rev=0;
ll tt=0;
ll dm[]={31,28,31,30,31,30,31,31,30,31,30,31};
for(ll i=0;i<12;i++)
{
for(ll j=1;j<=dm[i];j++)
{
whole[tt]= (6-i-1)*(6-i-1)+abs(j-15);
rev+=min(n,whole[i*dm[i]+j])*wt;
tt;
}
}
ll surplus = t-wt;
ll need = r-rev;
ll poss=0;
if(need<=0)
cout<<0;
else
{
ll ans=0;
ll l=0;
ll r1=n;
while(l<r1)
{
ll mid =(l+r1)/2;
ll extra =0;
ll tt=0;
mid=14;
for(ll i=0;i<12;i++)
{
for(ll j=1;j<=dm[i];j++)
{
ll withtv = mid;
ll without = n-mid;
if(min(whole[tt],n)<=without)
{
extra = extra + min(whole[tt],n)*wt;
}
else
{
extra = extra + (min(whole[tt],n)-without)*t + without*wt;
}
tt++;
}
}
cout<<extra<<endl;
//
if(extra>r)
{
poss=1;
r1=mid;
}
else
{
l=mid+1;
}
}
if(poss==0)
{
cout<<n;
}else
cout<<l;
}
return 0;
}
@zoso_floyd please can you check my solution (CEZzOc - Online Python3 Interpreter & Debugging Tool - Ideone.com) . I don’t understand where I am wrong.
Here is mine (CEZzOc - Online Python3 Interpreter & Debugging Tool - Ideone.com) . But gives WA. I don’t know why
Can anyone share the solution for problem A? I am getting wrong answer. please help
bro, can you explain logic of this collision problem? i dont even understand the logic of single problem in that mockvita
simpley log(n)/log(2)+1
can anyone tell me why I was getting WA in 3rd question.i am just posting the main of my code
public static void main(String[] args) throws Exception {
Reader obj=new Reader();
int c=obj.nextInt();
ArrayList<Float> a=new ArrayList<>();
while(c-->0)
{
long x=obj.nextLong();
long y=obj.nextLong();
long v=obj.nextLong();
long dist;
float time;
dist=(long)(Math.sqrt(Math.pow(x-0, 2)+Math.pow(y-0, 2))); //calculating the distance of every car from origin
time=((float)dist)/v; // calculating the time required to reach origin for every car
a.add(time); // adding the time required by each car to reach origin in list
}
HashSet<Float> hs=new HashSet<>(); //Set to find each unique time for collision
ArrayList<Integer> b=new ArrayList<>();
for(int i=0;i<a.size();i++)
{
if(!hs.contains(a.get(i)))
{
hs.add(a.get(i)); //Adding unique collision time to set
}
}
for(Float numbers: hs)
{
b.add(Collections.frequency(a, numbers)); // Finding the frequency of each unique collision and storing it to a list
}
long answer=0;
for(int i=0;i<b.size();i++)
{
long collisions=b.get(i)*(b.get(i)-1)/2; // Finding total number of collisions using n*(n-1)/2 formula
answer+=collisions;
}
System.out.println(answer);
}
Anyone who did problem b in python and got AC, please post your solution. It very helpful for me.