uuid
string
repo_name
string
relative_path
string
content
string
category
string
algo_rel_score
float64
quality_score
float64
b37c3ab3-750d-4e42-a1d5-b44f1a5fd869
ishandutta2007/codeforces
heart_blue/normal/1719/A.cpp
#include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <bi...
ALGO
0.998668
4.785796
b5d5d0ca-74e1-4e9c-80ca-fa97d3f7f824
msussman42/amrex_implicit_interfaces
amrex-master/Src/LinearSolvers/MLMG/AMReX_MLNodeLaplacian_eb.cpp
#include <AMReX_MLNodeLaplacian.H> #include <AMReX_MLNodeLap_K.H> #ifdef AMREX_USE_EB #include <AMReX_algoim.H> #endif #ifdef AMREX_USE_OMP #include <omp.h> #endif namespace amrex { void MLNodeLaplacian::buildIntegral () { if (m_integral_built) { return; } BL_PROFILE("MLNodeLaplacian::buildIntegral()"); ...
ALGO
0.992454
5.056602
ea9c413d-c6c3-405c-93a0-ee421e1f36d3
Onesiphorus/kattis-solutions
ptice.cpp
#include<iostream> #include<string> using namespace std; int main(){ int n, aScore = 0, bScore = 0, gScore = 0, high; string answer; char adrian[100], bruno[100], goran[100]; cin >> n; cin >> answer; for (int i = 0; i < n; i++){ if (i % 3 == 0) adrian[i] = 'A'; else if (i % 3 == 1) adrian[i] = 'B'; else...
ALGO
0.999969
4.434195
a0b40dcc-0ffd-40db-98a4-25584a0a5634
AIcling/Algorithm
exams/202303/first.cpp
#include <iostream> using namespace std; int main(void){ long n,a,b; long long area =0; cin >> n >> a >> b; while(n--){ int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; if(x1>=0 && y1>=0 && x2<=a && y2 <= b){ area += (x2-x1)*(y2-y1); }else if(x2<=0 || y2<=0 || x...
ALGO
0.976841
3.459016
094d6e96-33df-4008-85a1-c3adb3179d49
karan-pawar-09/codeforces
Magical_Planks.cpp
/* author:Karan created:26.11.2021 21:05:43 */ #if true #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> using namespace std; #define ll long long #define all(ar) ar.begin(),ar.end() #define endl '\n' #define mset(a,x) memset(a,x,sizeo...
ALGO
0.999819
5.096975
5a8875a7-690c-4d57-a6d3-8b3b3f4491ea
tomoakiii/atcoder2
Archive/abc319/C_FalseHope.cpp
#include <bits/stdc++.h> using namespace std; int main(){ int search[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; // int search[] = { 7, 8, 5, 0, 4, 6, 2, 1, 3 }; int arr[9]; for (auto &a : arr){ cin >> a; } double falcnt = 0, allcnt = 0;; do { vector<int> c(9, 0); bool flg = ...
ALGO
0.999544
3.542084
cc403044-e4aa-40f5-be92-3dcc6f49d409
msiedlarek/minimal-linux
src/llvm/libcxx/test/std/ranges/range.adaptors/range.take.while/general.pass.cpp
// UNSUPPORTED: c++03, c++11, c++14, c++17 // Some basic examples of how take_while_view might be used in the wild. This is a general // collection of sample algorithms and functions that try to mock general usage of // this view. #include <algorithm> #include <cassert> #include <ranges> int main(int, char**) { { ...
TEST
0.850551
7.135994
e864cf48-31c6-4e44-873b-dfc2a9a188e5
MostafaMohamed2001/C-Data-Structure
.history/hello_20240714174801.cpp
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> arr(n); // Input array elements for (int i = 0; i < n; i++) { cin >> arr[i]; } int left = 0, right = n - 1 , dima_count = 0 , serja_count=0; bool serja_trun = true; while ...
ALGO
0.999976
4.421241
8a7b6c46-1666-4dad-89c9-758c0baeda5a
really-no-name/PersonalLeetCode
Code/1/3/1342/1342.cpp
/****************************************************************************** * 文件名: 1342 * 作者: BOLUN XU * 创建日期: 2025 * 版本: 1.0 * 描述: 将数字变成 0 的操作次数。 * 时间复杂度: O(Logn) * 空间复杂度: O(1) * 执行用时: 0 ms * 消耗内存: 7.81 mb ******************************************************************************/ #include <iostream>...
ALGO
0.99947
5.8814
9af2695e-e2f9-4d51-8579-7c2fede1a0a4
SifatAli008/C_Plus_Plus_and_DSA1
Library/P2.cpp
// min , max ,sort,revers,search,occurence // Created by Sifat Ali on 1/7/2024. // #include <iostream> #include <algorithm> #include <vector> using namespace std; bool sortprocess(int a,int b){ //for ascending //if(a<b)return true; //else return false; //for descinding if(a>b) return true; els...
ALGO
0.999877
4.144341
98645d57-ea89-462a-906a-985b02246354
raincross7/code-similarity
codes/train_code/problem161/problem161_14.cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for (int i = 0; i < (n); ++i) #define rep2(i,a,b) for (int i = (a); i < (b); ++i) int main(){ char a,b; cin>>a>>b; if(a=='H'){ if(b=='H') cout<< 'H' <<endl; else cout<< 'D' <<endl; } else{ ...
ALGO
0.99995
3.03465
458d1149-5ed3-4198-b4cc-f8d25d6c71cc
aanupam29/codeforces-problems
1057B - DDoS.cpp
#include <bits/stdc++.h> using namespace std; #define lli long long int #define ulli unsigned long long int #define li long int #define ff(i,a,b) for(int i=a;i<=b;i++) #define fb(i,b,a) for(int i=b;i>=a;i--) #define w(t) while(--t >= 0) #define l(s) s.le...
ALGO
0.998921
3.587303
44d544b7-0e19-46cf-b871-5bad13a8e604
ishandutta2007/codeforces
dreamoon_love_aa/normal/258/A.cpp
#include<stdio.h> #include<string> #include<math.h> #include<stdlib.h> #include<set> #include<bitset> #include<map> #include<vector> #include<string.h> #include<algorithm> #include<iostream> #define pb push_back using namespace std; string str; int main(){ int i,j,k,n; cin>>str; for(i=0;i<str.size()&&str[i]...
ALGO
0.99991
3.278899
4a4665c7-18b9-49ff-8e05-20d6e4e57ea5
Vibhuti0206/Graphs
Prim's logic algo.cpp
#include<bits/stdc++.h> using namespace std; class Graph{ public: int v; list<pair<int,int> >*adj; Graph(int v){ this->v = v; adj = new list<pair<int,int> > [v]; } void addEdge(int u,int v,int w){ adj[u].push_back(make_pair(v,w)); adj[v].push_back(make_pair(u,w)); } int findMinVertex(int *we...
ALGO
0.99999
4.071916
a3d63c7c-6c5a-4dae-8d1b-f3bb74e46265
ivanavd11/-Introduction_to_programming
Practicum by plamena-ilieva/Pract08/task_4.cpp
#include <iostream> void swap(int& a, int& b) { a = a ^ b; b = b ^ a; a = b ^ a; } int main() { int a, b; std::cin >> a >> b; swap(a, b); std::cout << a << " " << b; return 0; }
ALGO
0.999842
4.556322
ec380c22-b947-41a2-b507-7fdb0c014bc7
ishandutta2007/codeforces
m_99/normal/650/A.cpp
#include <bits/stdc++.h> using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 1000000000 int main(){ int n; cin>>n; map<int,long long> x,y; map<pair<int,int>,long long> xy; for(int i=0;i<n;i++){ int a,b; scanf("%d %d",&a,&b); x[a]++; y[b]...
ALGO
0.999847
4.104396
979ce8a9-dcab-4e73-b6fa-ba5ad56d603e
ishitacs/LeetCode
minimum-cost-to-move-chips-to-the-same-position/minimum-cost-to-move-chips-to-the-same-position.cpp
class Solution { public: int minCostToMoveChips(vector<int>& p) { int e=0; int o=0; for(auto i:p) { if(i%2==0) e++; else o++; } return min(e,o); } };
ALGO
0.999509
5.539733
81fd9c93-bd40-4b85-ba69-b9c476c7d5a7
lzl200102109/BLAS
dlib-18.18/examples/config_reader_ex.cpp
/* This is an example illustrating the use of the config_reader component from the dlib C++ Library. This example uses the config_reader to load a config file and then prints out the values of various fields in the file. */ #include <dlib/config_reader.h> #include <iostream> #include <fstream> #inc...
TOOL
0.889638
7.649409
fe52cda5-e6ab-4dd7-b23c-f3c8182a07a0
jrpfaria/IC
assignment2/src/audio_decoder.cpp
#include <iostream> #include <vector> #include <sndfile.hh> #include <math.h> #include "bitstream.h" #include "golomb.h" using namespace std; int main(int argc, char *argv[]) { if (argc < 3) { cerr << "Usage: " << argv[0] << " <input file> <output file>\n"; return 1; } BitStream bitstreamInput = BitStream(ar...
TOOL
0.878426
5.610735
fa6d694c-5805-4b11-84b6-f70ac419f15c
kingkk31/BOJ
source code/9455_박스.cpp
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <queue> #include <vector> #include <stack> #include <set> #include <map> #include <list> #include <string> #include <string.h> #include <math.h> #include <algorithm> #include <malloc.h> #include <functional> #pragma warning(disable:4996) using namespac...
ALGO
0.999922
3.304209
3b9971e3-09c9-4487-af40-d4a767060d2c
xmlb88/algorithm
leetcode/array/495.findPoisonedDuration.cpp
#include <iostream> #include <vector> using namespace std; // think too much int findPoisonedDuration(vector<int>& timeSeries, int duration) { int n = timeSeries.size(); if (n == 0) return 0; vector<pair<int, int>> time; for (auto series : timeSeries) { time.push_back({series, series + duration...
ALGO
0.999841
5.609207
11d6fad5-9b46-49b8-aa4a-bdf21c97e804
Saleh7127/CPP-solution-by-Fellow_junior
At coder/at aclb.cpp
#include <bits/stdc++.h> using namespace std; #define ll long long #define test int t; cin>>t; for(int cs=1;cs<=t;cs++) int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ll a,c,d,e; cin>>a>>c>>d>>e; if(c>=d && c<=e) cout<<"Yes"<<endl; else if(e>=a && e<=c) cout<<"Yes"<<endl; else ...
ALGO
0.999699
3.046304
b034f040-408a-4d8d-8f96-e18b39b4980b
VikrantSingh16/DSA
Searching&Sorting/Day-15-SearchingAndSorting/searchInRotatedAray.cpp
/*33. Search in Rotated Sorted Array Medium 8989 713 Add to ListShareThere is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is rotated at an unknown pivot index k (0 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums...
ALGO
0.999975
5.775529
99348519-b1b0-48cc-bd1b-d667aa5e396c
morgangthorne/Chapter_5_Exercise_20_-Random_number_Guessing_Game
Chapter_5_Exercise_20_ Random_number_Guessing_Game.cpp
/* Filename: Chapter_5_Exercise_20_ Random_number_Guessing_Game.cpp Programmer: Morgan Thorne Date: April 2025 Requirements: -generate a random number that asks user to guess what number it is -if users guess is too hiht the program should respond with too high -same for if the guess is too low -Program should use a lo...
TOOL
0.886897
4.984492
f8cbe251-584e-4dfe-bde9-d30ad567b25c
dbekinalkar/leetcode
cpp/90.subsets-ii.cpp
/* * @lc app=leetcode id=90 lang=cpp * * [90] Subsets II */ // @lc code=start class Solution { public: vector<vector<int>> subsetsWithDup(vector<int>& nums) { std::sort(nums.begin(), nums.end()); vector<vector<int>> res; vector<int> curr; subset(res, nums, curr, 0); ...
ALGO
0.999837
6.621886
fefe09da-7765-4084-b58b-21dd7c3f53ed
kamrul35728/mst_gready_approach
primsAlgorithm.cpp
#include <bits/stdc++.h> using namespace std; int spanningTree(int V, vector<pair<int, int>> adj[]){ priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; vector<int> vis(V+1, 0); pq.push({0, 1}); int sum = 0; while (!pq.empty()){ auto it = pq.top(); pq....
ALGO
0.999983
4.680613
248579bc-a48a-48fb-933b-ab9cb5bff941
jaketurelli/leetcode
c++/src/003_climbing-stairs.cpp
/////////////////////////////////////////////// /// @file 003_climbing-stairs.cpp /// @author Jake Turelli (<EMAIL>) /// @brief https://leetcode.com/problems/climbing-stairs/ /// @version 0.1 /// @date 2021-12-30 /// /// @copyright Copyright (c) 2021 /// /////////////////////////////////////////////// // You are climb...
ALGO
0.999887
5.794515
5dff8588-9769-48ed-97ec-9ccd38a977a0
diego-gabriel/accountme
ICPC-UMSS/LongWeekendContest2/195C-CodeForces.cpp
#include <iostream> #include <map> #include <cstring> #include <cstdio> #include <queue> #include <vector> #include <stack> using namespace std; int n; vector <string> separar (string cad) { vector <string> res; if (cad != "") { while(!cad.empty() && cad[0] != 't' && cad[0] != 'c') cad.erase(cad.begin()); ...
ALGO
0.922656
4.326046
e8e52ee0-c696-4946-bf92-19cd96b49a87
rky-cse/Competitive-Programming
1690F.cpp
#include <bits/stdc++.h> using namespace std; //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key //MARK:- MACROS=========...
ALGO
0.99995
4.299066
52065d72-0f1f-41d9-ad0d-d5f5fe80a233
lhaquoc/DS
DSLessons/26_Remove_Duplicates_From_Sorted_Array.cpp
#include <iostream> #include <vector> using namespace std; int removeDuplicates(vector<int>& a) { int n = a.size(); int curIndex = 0; if (n == 0){ return 0; } for(int i = 0; i < n; i++) { if(a[i] != a[curIndex]) { curIndex++; a[curIndex] = a[i]; } ...
ALGO
0.99949
5.060236
8206adb6-dc74-4b70-9601-0c981dc26ab8
kaloi-noggins/competicao_programativa
uri/cpp/2950.cpp
#include <bits/stdc++.h> using namespace std; int main() { double a, b, c; cin >> a >> b >> c; cout << fixed << setprecision(2) << a / (b + c) << endl; return 0; }
ALGO
0.999564
3.670132
ee7e9999-9bea-4ba0-8490-e132660b691a
ShawnDS/Shawn
Sort/MergeSort.cpp
//未知的bug: 中文多行注释结尾的汉字与 */ 之间要有空格 /* 归并排序,其的基本思路就是将数组分成二组A,B,如果这二组组内的数据都是有序的, 那么就可以很方便的将这二组数据进行排序。如何让这二组组内数据有序?可以将A,B组 各自再分成二组。依次类推,当分出来的小组只有一个数据时,可以认为这个小组组内已经 达到了有序,然后再合并相邻的二个小组就可以了。这样通过先递归的分解数列,再合并数 列就完成了归并排序。这里待排序数列是a[],中间用temp[]转存,最后排好序的数列还是a[], 每次的二分只是将a[]分为两部分,并没有分别放入两个数组中,这样节约空间,不必开辟多个 数组来存放 */ #include <iostre...
ALGO
0.999805
3.825634
583dc2cc-7ae4-43dd-a1af-992796c5985d
ishandutta2007/codeforces
yuu/normal/632/C.cpp
#include <bits/stdc++.h> using namespace std; #define FOR(i, j, k) for(int i=(j); i<=(k); i++) #define FFOR(i, j, k) for(int i=(j); i<(k); i++) #define DFOR(i, j, k) for(int i=(j); i>=(k); i--) #define bug(x) cerr<<#x<<" = "<<(x)<<'\n' #define pb push_back #define mp make_pair #define setbit(s, i) (s|=(1LL<<(i))) #defi...
ALGO
0.999733
3.573433
5324af5f-d80d-4358-b5dd-fd81fd9b077c
shivamkrs89/Graphs-and-Trees
Subtree.cpp
You are given two binary trees root, and target. Return whether target is a subtree of root — that is, whether there's a node in root that is identically same in values and structure as root including all of its descendants. Example 1 Input Visualize root = 1 2 3 4 5 6 7 target = 3 4 5 6 7 Output true E...
ALGO
0.99997
6.212085
36bf229e-af2a-4c7d-b58b-4da1b3f4bd86
turjo997/Online-Judge-Solutions
LeetCode/Two Sum.cpp
class Solution { public: vector<int> twoSum(vector<int>& v, int k) { int n = int(v.size()); vector<pair<int,int>> v1; for(int i = 0; i<n;++i){ v1.push_back(make_pair(v[i] , i)); } sort(v1.begin() , v1.end()); vector<int> a; int i = 0 , j = ...
ALGO
0.999953
5.571023
46bdd1a9-b339-4a2a-9593-a63e1511d1db
chenghuasheng/NOIP
[基本算法]穷举/matches.cpp
#include <fstream> using namespace std; ifstream fin("matches.in"); ofstream fout("matches.out"); int n; int huocai[2223]={6,2,5,5,4,5,6,3,7,6,0}; int get_huocai(int x){ if (huocai[x]>0) return huocai[x]; else { int r=x % 10; int q=x / 10; int ret=huocai[r]+get_huocai(q); huocai...
ALGO
0.999387
4.507908
11118395-a0f6-45d4-aecb-6f1d9f44dcdd
lclpsoz/competitive-programming
ARCHIVE/2019-09-21-1420/139A.cpp
#include "bits/stdc++.h" using namespace std; ////////////// Prewritten code follows. Look down for solution. //////////////// #define x first #define y second #define len(x) ((int)(x).size()) using pii = pair<int, int>; using ll = long long; using llu = long long unsigned; using ld = long double; const ld EPS = 1e-9...
ALGO
0.999877
3.012449
6ad7ca36-2a9b-4aaa-b1f8-c119d4c1e077
RyanRamadhan11/Belajar-C-plusplus
latihan/menghitung-nilai-mahasiswa.cpp
//Ryan Ramadhan #include <iostream> #include <conio.h> #include <stdio.h> using namespace std; struct nilai { char nama[20]; char npm[15]; float tugas; float kuis; float uts; float uas; }; struct hasil { float tugas; float kuis; float uts; float uas; float akhir; char h...
TOOL
0.979725
3.108648
c7891d35-778d-4c83-ace0-d5136a55976a
Vikasgupta04/Bootcamp_Jan_Feb_2025
Day2/q10.cpp
// WAP to check if a number is prime #include <bits/stdc++.h> using namespace std; int main() { int num; cout << "Enter a number - "; cin >> num; int count = 0; for (int i = 1; i <= num; i++) { if (num % i == 0) { count++; } } if (count == 2) { ...
ALGO
0.998536
4.425601
5259ad73-cdf1-4f17-9e45-ceff8274fbef
Dusk1706/cp-library
Grafos/MST/KruskalsAlgorithm.cpp
#include <bits/stdc++.h> //Pura gente del coach moy using namespace std; #define ENDL '\n' #define f first #define s second #define all(s) begin(s), end(s) #define rall(n) n.rbegin(), n.rend() #define FOR(x, b) for(int x = 0; x <b; x++) #define FORE(x, a, b) for(int x = a; x <= b; x++) #define FORR(x, a, b) for(int x =...
ALGO
0.999983
4.52934
2b8b2e22-0a62-495e-9514-082a13e03c47
gravitsapa/3D-renderer
src/geometry/plane.cpp
#include <plane.h> namespace project { namespace geometry { Plane::Plane(Coordinate a, Coordinate b, Coordinate c, Coordinate d) : normal_(a, b, c), d_(d) { } Coordinate Plane::Equation(const Point3d& point) const { return point.dot(normal_) + d_; } bool Plane::IsInHalfPlain(const Point3d& point) const { re...
ALGO
0.972318
5.923678
cc658619-8917-477b-b90f-50e4588e3d2b
ravindar-10/IP
Balanced Team.cpp
//https://codeforces.com/problemset/problem/1133/C #include <bits/stdc++.h> using namespace std; #define ll long long #define vl vector<long long> #define vi vector<int> #define vb vector<bool> #define pql priority_queue<long long> #define pqp priority_queue<pair<ll,ll> > using namespace std; int main() {ios_base::sync...
ALGO
0.999853
3.99026
62118a77-0f38-47f2-b001-7d3e2089f4f5
GeekyMatrix/Code
DP/General/Painting the Walls(2742).cpp
class Solution { public: //Recursion int n; int solve(int idx , vector<int>& cost, vector<int>& time , int remaining){ //BASE CASE if(remaining <= 0) return 0; //NO COST if(idx >= n) return 1e9; //INVALID CASE //EXPLORE int paint_idx = cost[idx] + solve(idx + 1 , cost , time , remaining - 1 - t...
ALGO
0.999962
5.759836
0dd6c18f-47b1-4562-94f4-9bf00e08bba1
pkorivi/model_car
catkin_ws_user/src/mpc_control/src/Eigen-3.3/doc/examples/TemplateKeyword_simple.cpp
#include <Eigen/Dense> #include <iostream> using namespace Eigen; void copyUpperTriangularPart(MatrixXf& dst, const MatrixXf& src) { dst.triangularView<Upper>() = src.triangularView<Upper>(); } int main() { MatrixXf m1 = MatrixXf::Ones(4,4); MatrixXf m2 = MatrixXf::Random(4,4); std::cout << "m2 before copy:"...
TOOL
0.960071
5.172663
e772f9ea-d9f1-42fd-8d57-612504e3893e
aftabfarhanarko/Comparative-Programming-all-Code
C++_Array_DSA_problem_sloved/first_problemSlvd.cpp
#include<iostream> using namespace std; //any element inside array would be >= zero? int arr[12]={11,13,14,16,18,19,21,23,24,26,27,90}; int main(){ int max=-1; for(int i=0; i<12; i++){ if(arr[i]>max){ max = arr[i]; } } cout<<max; }
ALGO
0.997253
3.4203
15865d30-8658-496d-b18d-b644fd79cfff
tuanliz0403/CSES
Solved/Palindrome Reorder.cpp
#include <bits/stdc++.h> using namespace std; #define INT long long #define MOD 1000000007 int main(){ string st; int numb[27], odd = 0; char odd_letter; fill_n(numb, 27, 0); cin >> st; sort(st.begin(), st.end()); for(int i = 0; i < st.length(); i++) numb[st[i] - 'A']++; st = ""; f...
ALGO
0.999997
4.160453
416d4ba9-711d-4e87-b9ae-5989b4173f2d
ZacBlanco/cse291w21
euphony/thirdparty/z3/src/ast/rewriter/bv_elim.cpp
#include "ast/rewriter/bv_elim.h" #include "ast/bv_decl_plugin.h" #include "ast/rewriter/var_subst.h" #include "ast/rewriter/rewriter_def.h" #include <sstream> bool bv_elim_cfg::reduce_quantifier(quantifier * q, expr * body, expr * const * new_patterns,...
ALGO
0.992981
5.86984
68dbebed-b15a-4637-abe1-345d0791402d
omich12/CPP-Assignment
Patterns/Q4.cpp
// Write a C++ program to make such a pattern like a pyramid with an asterisk. #include <iostream> using namespace std; int main() { int i, j, k; int space, rows; cout << "Enter number of rows: "; cin >> rows; space = rows + 4 - 1; // Calculate the number of spaces for formatting. for (i =...
ALGO
0.985679
5.216549
856032b3-3f39-452f-a921-f69a8ceca390
spark-1/algorithm
Baekjoon/백준2506번 점수계산.cpp
#include <iostream> int main() { int N, num, score = 0, sum = 0; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &num); num == 1 ? score++ : score = 0; sum += score; } printf("%d\n", sum); }
ALGO
0.999716
3.39717
73fe9305-2328-49bd-bf97-5ffec9761542
oeddyo/algorithm
usaco/numtri.cpp
/* ID: xieke.b1 PROG: numtri LANG: C++ */ #include <iostream> #include <fstream> #include <string> #include <string.h> using namespace std; const int MAXN = 1002; int dp[MAXN][MAXN]; int d[MAXN][MAXN]; ofstream fout("numtri.out"); ifstream fin ("numtri.in"); int N; const int INF = 999999999; void work(){ for(int ...
ALGO
0.999919
3.545053
2fa7cfff-eb28-48bf-bd40-9a18b44357ae
quethaibinh/code_ptit_DSA
DSA11011.cpp
#include<bits/stdc++.h> using namespace std; #define ll long long const int MOD = 1e9 + 7; bool check; struct node{ int val; node* left; node* right; node(int x){ val = x; left = right = NULL; } }; void makeNode(node* root, int u, int v, char c){ if(c == 'L') root->left = new ...
ALGO
0.999982
4.393148
83919d3d-7a04-4eb9-b856-f20132e21f9f
Velocifero1052/white_belt_CPP
src/is_palindrome.cpp
// // Created by comme on 4/2/2023. // #include<string> #include<vector> bool IsPalindrom(std::string word){ for(int i = 0; i < word.length() / 2; i++){ if(word[i] != word[word.length() - 1 - i]) return false; } return true; } std::vector<std::string> PalindromFilter(std::vector<std::s...
ALGO
0.996629
5.787562
24af94f3-a310-4ae1-b239-767fe9b56cfe
dtarb/TauDEM
src/DropAnalysis.cpp
/* DropAnalysis function that applies a series of thresholds (determined from the input parameters) to the input ssa grid and outputs in the drp.txt file the stream drop statistics table. David Tarboton, Dan Watson Utah State University May 23, 2010 */ // This software is distributed from http://...
DATA
0.997393
4.669067
73271fab-c5ff-4dbc-b034-ad888622375c
tumbaba/C-
AS백준2/14888.cpp
#include <iostream> using namespace std; int Max = -100000000; int Min = 100000000; int oper[4]; int Arr[11]; int N; void DFS(int pl, int su, int ml, int di, int depth, int val) { if (depth == N-1) { if (Max < val) { Max = val; } if (Min > val) { Min = val; } return; } if (pl > 0) { DFS(...
ALGO
0.999981
3.789306
2f262036-ae45-4f7f-8fc9-7363d93a625e
jiangyc2024/NumCSE
Assignments/PolishedCodes/IterativeMethods/LocationEstimation/solution/main.cpp
/* ********************************************************************** * Course "Numerical Methods for CSE", R. Hiptmair, SAM, ETH Zurich * Author: R. Hiptmair * Date: January 2022 */ #include <Eigen/Dense> #include <Eigen/QR> #include <Eigen/SVD> #include <cassert> #include <cmath> #include <iomanip> #include ...
ALGO
0.999879
5.426583
1b25050f-5e58-41d7-b2e1-71ee10051446
coderSomya/Competetive-Programming
codeforces/weirdSum.cpp
/* problem link -> https://codeforces.com/problemset/problem/1648/A */ #include <bits/stdc++.h> using namespace std; #define loop(i,l,r) for(int i=l; i<r; i++) #define int long long #define pb push_back #define vi vector<int> #define mkp make_pair<int,int> #define ...
ALGO
0.999947
3.398604
3dc3a1dd-e7fc-4d52-b6cc-567a2cb5e87a
ishandutta2007/codeforces
roundgod/normal/1609/A.cpp
#include<bits/stdc++.h> #define MAXN 100005 #define INF 1000000000 #define MOD 1000000007 #define F first #define S second using namespace std; typedef long long ll; typedef pair<int,int> P; int t,n; ll a[MAXN]; int main() { scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) ...
ALGO
0.999968
3.922589
234578f1-47e3-40f3-9188-8b480d2ae165
ishandutta2007/codeforces
w0nsh/normal/1118/C.cpp
#include <bits/stdc++.h> #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, n) for(auto &i : n) #define SZ(x) (int)(x).size() #define PR std::pair #define MP std::make_pair #define X first #define Y second typedef long long ll; typedef std::pair<int, int> ...
ALGO
0.999947
3.311043
47e47638-efa0-4508-8500-21839cc84dc0
Haribala-09/hyprdots
User/History/1e2224/Durj.cpp
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == k) { int ans = 1, c = 1; for (int i = 1; i < n; i += 2) { if (a[i] != c++) { break; } ans++; } cout << ans << '\n'; return...
ALGO
0.999909
4.20763
9e6e0933-84ae-489a-a99f-166a9d7f9976
SovietPower/My-OI-ACM
Codeforces/CF 1114 2.10/B.Yet Another Array Partitioning Task.cpp
#include <set> #include <map> #include <cstdio> #include <cctype> #include <vector> #include <cstring> #include <algorithm> #define pc putchar #define gc() getchar() typedef long long LL; const int N=2e5+5; struct Node { int v,p; bool operator <(const Node &x)const { return v==x.v?p<x.p:v>x.v; } }A[N]; inline i...
ALGO
0.999964
3.243275
15e88cdf-8656-49fc-8508-8f01dac711ef
blockchaincavs/LeetCode
MaxDepthBST_104/main.cpp
#include <iostream> struct TreeNode { int val; TreeNode *left; TreeNode *right; }; /* * Can use preorder, inorder, or postorder search */ int maxDepth(TreeNode* root) { // base case if (!root) return 0; int left = maxDepth(root->left); int right = maxDepth(root->right); // ...
ALGO
0.999886
6.438511
33d192bd-286e-42a9-91dd-93a41def19fb
item28/tosqa-ssb
apps/driver/setpoint.cpp
// Drive the stepper motor. This is a separate task which takes incoming // setpoint commands and makes the stepper perform the requested motion. // Setpoints include a target position as well as an "exit" velocity. // If there is no work, the stepper will stop as quickly as possible. #define SETPOINT_QUEUE_SIZE 250 ...
TOOL
0.894393
6.045626
15799a45-1da8-47c9-83e5-6ad0d9e53145
black-shadows/LeetCode-Topicwise-Solutions
C++/random-point-in-non-overlapping-rectangles.cpp
// Time: ctor: O(n) // pick: O(logn) // Space: O(n) class Solution { public: Solution(vector<vector<int>> rects) : rects_(move(rects)), gen_{(random_device())()} { for (const auto& rect : rects_) { const auto width = rect[2] - rect[0] + 1; const auto height ...
ALGO
0.999856
7.418826
361f255f-1ae1-45bb-aa2c-a14b0f372091
ttsugriy/acmp.ru
839.cpp
#include <iostream> #include <string> int main() { std::string seq; std::cin >> seq; std::cout << (seq.find('0') == std::string::npos ? "YES" : "NO"); }
ALGO
0.998339
5.170495
101b4da7-a8b8-4d77-8073-427431e9c246
Abdullah88909/348-lab
EC LAB#1.cpp
#include <iostream> #include <iomanip> #include <string> using namespace std; double extractNumeric(const string& str); int main() { string input; while (true) { cout << "Enter a string (or 'END' to quit): "; cin >> input; if (input == "END") { break; } ...
TOOL
0.96507
6.690454
b6541121-4997-48e7-a698-ada618bd9d48
TechnicalPlayerZd/Infernal-Blueberries-Leetcode
1160-letter-tile-possibilities/letter-tile-possibilities.cpp
class Solution { public: int numTilePossibilities(std::string tiles) { int n = tiles.length(); std::vector<int> counts(26, 0); std::vector<int> fac(n + 1, 1); for (int i = 1; i <= n; i++) { fac[i] = i * fac[i - 1]; } for (char c : tiles) { cou...
ALGO
0.999913
6.908876
6e438c2a-207e-4d35-ad93-c41758bfcc17
metehkaya/Algo-Archive
Problems/CSES/Sorting_and_Searching/Reading_Books.cpp
#include <bits/stdc++.h> #define maxn 200001 using namespace std; typedef long long LL; int n; int ar[maxn]; LL sum[maxn]; int main() { scanf("%d",&n); for( int i = 1 ; i <= n ; i++ ) scanf("%d",&ar[i]); sort(ar+1,ar+n+1); for( int i = 1 ; i <= n ; i++ ) sum[i] = sum[i-1] + ar[i]; int last = 0; for( int i =...
ALGO
0.999196
3.426285
600f5bf0-5a44-42f8-8ca7-b49a4dae194b
Darklul03/IT007-LAB
Lab4/srtf.cpp
#include <iostream> #include <string> #include <queue> #include <vector> #include <map> #include <algorithm> #include <iomanip> #include <stdio.h> using namespace std; // struct for priority queue struct Process { int pid; int arrival; int burst; int remaining; int waiting; int turnaround; ...
ALGO
0.999842
4.522607
9d8c82f5-b136-42fd-ab7a-0e34d19095a7
darrentimotius/datStruct
exercise/quiz2/avlTree.cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define gc getchar(); struct Node { int id; int exam_pass; int have_c_grade; int international_achievements; int value; int height; Node* left; Node* right; }*root = NULL; Node* createNode(int id, int exam_p...
ALGO
0.999965
3.652968
9e0231d3-f8fc-4a5b-a8d9-ed8f61d512fb
lasvegasrc/Las-Vegas-Reconstruction
src/tools/mpi/segmentize.cpp
// // Created by eiseck on 08.12.15. // #include <fstream> #include "NodeData.hpp" #include <algorithm> #include "LargeScaleOctree.hpp" #include <string> #include <sstream> using namespace lvr; void printTest(Vertexf v) { cout << v; } int main(int argc, char** argv) { clock_t begin = clock(); ifstream in...
ALGO
0.914187
5.1075
6477274b-6658-4d9e-b8d1-c4ffffedcf35
saurabhnathofficial/CampusIConnect
InvertedTriangle.cpp
#include <iostream> using namespace std; int main() { int i,j,n; cin>>n; for(i=0; i<n; i++){ for(j=0;j<=i; j++){ cout<<" "; } for(j=0;j<n-i; j++){ cout<<i+1; } cout<<endl; } char ch = 'A'; for(i=0; i<n; i++){ ...
ALGO
0.999769
3.517456
7797b792-e41d-47a2-a31d-fd4a7323e9fe
Imon739/Algorithm
Divide Conquer/Binary Search.cpp
#include <bits/stdc++.h> using namespace std; int binarySearch(int arr[], int low, int high, int x) { if (high >= low) { int mid = low + (high - low) / 2; if (arr[mid] == x) return mid; if (arr[mid] > x) return binarySearch(arr, low, mid - 1, x); return b...
ALGO
0.999866
5.476357
7f6437c5-aa01-4504-9dd1-184fe5ec8138
WhyDoICode/PixelatedPassion
CompetitiveCpp/Basic/stringproblem3.cpp
/* Write a program to concatenate two strings without using any string library functions. */ #include <iostream> using namespace std; int main() { string a,b, res; cin >> a >> b; cout << a + b; return 0; }
ALGO
0.959372
4.924652
c8c2cd6b-0df6-4cab-9b85-d4abf02f8b02
smuskova/C-
zad8 funkcii.cpp
#include<iostream> #include<cmath> using namespace std; int prosto(int n) { int a; if(a==2 or a==3); { int d=3; while((d<=sqrt(a)) and (a%d!=0)) d=d+2; if(a%d!=0); } return prosto; } int main () { int n,m; cin>>n>>m; cout<<prosto(n,m)<<endl; return 0; }
ALGO
0.999864
3.664146
665b9eef-c9cc-48cc-85b9-073bb87b1f5d
carterqberry/SQLite
Stuff/ACCU/code/C07/PriorityQueue7.cpp
using namespace std; template<class T, class Compare> class PQV { vector<T> v; Compare comp; public: // Don't need to call make_heap(); it's empty: PQV(Compare cmp = Compare()) : comp(cmp) {} void push(const T& x) { v.push_back(x); // Put it at the end // Re-adjust the heap: push_heap(v.begin(), ...
ALGO
0.99967
4.807568
41515002-81fd-425f-b511-59f5c0f278a9
PranjalPal75389/love_babbar_cpp
lecture 3 and 4 patterns/lecture 4/star/tempCodeRunnerFile.cpp
#include<iostream> using namespace std; int main(){ int i=1,n; cout<<"Enter a number :"; cin>>n; while(i<=n){ int j=i; while(j<=i){ cout<<i; j++; } cout<<endl; i++; } return 0; }
ALGO
0.999902
3.550626
95b7eab0-e774-4f78-bb6f-35c90edc300c
karygauss03/Leetcode-Solutions
1552-magnetic-force-between-two-balls/1552-magnetic-force-between-two-balls.cpp
class Solution { private: bool isPossible (vector<int>& position, int m, int mid) { int cur = position[0]; --m; for (int i = 1; i < position.size(); ++i) { if (m == 0) { return true; } if (position[i] - cur >= mid) { --m; ...
ALGO
0.99998
5.669638
4c53935f-2ed5-4f2c-9e2b-8ae237d870fa
dorian-gabIer/Klasa_2AG
XIV Tydzień informatyki/wez.cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, numb = 1; cin >> n; for(int i = 0; i < n; i++) { if(i%2 == 0) { for(int j = 0; j < n; j++) { cout << numb << " "; ...
ALGO
0.999976
3.688821
766dc6ec-558b-4372-8ca2-8558bbb5ece0
pongsaphol/submission
evaluator/o62/mar/c2/treesim.cpp
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second using namespace std; const int N = 2e5+5; int n; vector<vector<int> > g(N); pii dp[N]; pii add(pii a, pii b) { return pii(a.x + b.x, a.y + b.y); } pii sub(pii a, pii b) { return pii(a.x - b.x, a.y - b.y); } set<pii> s; pii fll; pi...
ALGO
0.998997
4.003166
b068f91a-7032-479d-a7cf-3da74d40fcfd
ZhenyingZhu/ClassicAlgorithms
src/CPP/src/leetcode/FactorCombinations.cpp
/* * [Source] https://leetcode.com/problems/factor-combinations/ * [Difficulty]: Medium * [Tag]: Backtracking */ #include <iostream> #include <vector> using namespace std; // [Solution]: Backtracking // [Corner Case]: Notice the number itself should not included in the result class Solution { public: vector<...
ALGO
0.999542
6.435406
941735c7-84e8-4065-9899-14d657ab5362
VedantPatil3110/DSA
Difficulty: Medium/Search Pattern (Rabin-Karp Algorithm)/search-pattern-rabin-karp-algorithm.cpp
class Solution { public: vector<int> search(string &pat, string &txt) { const int d = 256; const int q = 101; int m = pat.size(); int n = txt.size(); vector<int> result; if (m > n) return result; int h = 1; for (int i = 0; i < m - 1; i++) ...
ALGO
0.999933
6.046556
c51f51d6-71b3-4b5f-99a0-75ab45142903
xarkenz/advent-of-code
2022/cpp/day08.cpp
// // Created by xarkenz on 12/08/22. // #include "adventofcode.h" void day08() { std::ifstream input(getPath("day08.txt")); if (!input.is_open()) { std::cerr << "Unable to open 'day08.txt'\n"; return; } std::vector<std::string> trees; std::string line; while (input.good()) { ...
ALGO
0.995842
6.064348
3e7ac8fb-0bf3-47c7-b4a4-a54110f3fda0
xiashuang2020/leetcode-solutions
111.cpp
// // Created by pyxisha on 2021/8/22. // #include <vector> #include <iostream> #include <queue> #include <algorithm> struct treeNode { int val; treeNode *left; treeNode *right; treeNode() : val(0), left(nullptr), right(nullptr) {} treeNode(int x) : val(x), left(nullptr), right(nullptr) {} tre...
ALGO
0.999954
6.144207
967bc6f0-0b80-4a72-9965-bf6062cea2e1
BlueMobiusUser/wallet
src/wallet/fees.cpp
#include <wallet/fees.h> #include <wallet/coincontrol.h> #include <wallet/wallet.h> CAmount GetRequiredFee(const CWallet& wallet, unsigned int nTxBytes) { return GetRequiredFeeRate(wallet).GetFee(nTxBytes); } CAmount GetMinimumFee(const CWallet& wallet, unsigned int nTxBytes, const CCoinControl& coin_control, Fe...
ALGO
0.992153
6.982274
06fa8d0d-b099-4978-ac4f-87f1332acb38
ArtDu/DA
exam/code/sem_2/fft/main.cpp
#include <iostream> #include <vector> #include <complex> using namespace std; typedef complex<double> cd; vector<cd> fft(vector<cd> &a) { int n = a.size(); if (n == 1) return a; vector<cd> w(n); for (int k = 0; k < n; ++k) { double alpha = (2 * M_PI * k) / n; w[k] = cd(round(cos(al...
ALGO
0.999943
3.397295
1809bd2f-8691-45c2-b7e4-af4c73856a3d
Adi2209/DSA
maxPerformanceOfATeam.cpp
class Solution { public: int maxPerformance(int n, vector<int>& speed, vector<int>& efficiency, int k) { priority_queue<int, vector<int>, greater<int>> heap; vector<vector<int>> worker; vector<int> tmp(2,0); for (int i = 0; i < n; i++) { tmp[0] = speed[i]; tmp...
ALGO
0.99989
5.137306
410eec14-0252-4d69-85f9-e9e14d8c7b23
ishandutta2007/codeforces
sd0061/normal/552/B.cpp
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <string> #include <queue> #include <vector> #include <cctype> #include <set> using namespace std; typedef long long LL; const int N = 100005; int n; void work() { LL res = 0; cin >> n; for (int i = 1...
ALGO
0.99986
3.659488
83007daa-aef3-4f0a-85d9-4b7b243a6a4b
bablookr/ds_algo
Part 1 - Data Structures/DLL2.cpp
#include <iostream> using namespace std; struct Node{ int data; Node* next; Node* prev; }; Node* newnode(int data){ Node* temp = new Node(); temp->data = data; temp->next = NULL; temp->prev = NULL; return temp; } Node* push(Node* head,int data){ Node* temp = newnode(data); tem...
ALGO
0.99999
5.127668
0edec3a0-2e81-48ee-bad4-6105464e9a9f
gnuborg/Githammer
SparCraft/source/AlphaBetaSearch.cpp
#include "AlphaBetaSearch.h" using namespace SparCraft; AlphaBetaSearch::AlphaBetaSearch(const AlphaBetaSearchParameters & params, TTPtr TT) : _params(params) , _currentRootDepth(0) , _TT(TT ? TT : TTPtr(new TranspositionTable())) { for (size_t p(0); p<Constants::Num_Players; ++p) { // set ordered...
ALGO
0.999824
5.49984
1d309dbb-7d8d-4d52-a60e-2673398495b6
MultiDCP/BOJPractice
c++/1676.cpp
#include <bits/stdc++.h> using namespace std; int n, res; int main(void){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; res += n/5; res += n/25; res += n/125; /* while(n >= 5){ res += n / 5; n /= 5; } */ cout << res; return 0;...
ALGO
0.999552
3.966479
96f37296-864a-4b4a-8828-57bcb89b5bcd
pradeep891/LeetCode-and-Gfg-Practice
Find the longest string - GFG/find-the-longest-string.cpp
//{ Driver Code Starts //Initial Template for C++ #include <bits/stdc++.h> using namespace std; // } Driver Code Ends //User function Template for C++ class Solution { public: bool static cmp(string a , string b){ if(a.size() == b.size()) return a < b; return a.size() > b.size(); } string...
ALGO
0.999943
6.193366
63d58e9c-cf75-4dcd-8c80-6eefe10ac7e9
mypiggiesbank2022/piggie
src/timedata.cpp
#include "timedata.h" #include "chainparams.h" #include "guiinterface.h" #include "netbase.h" #include "sync.h" #include "util.h" #include "utilstrencodings.h" static CCriticalSection cs_nTimeOffset; static int64_t nTimeOffset = 0; /** * "Never go to sea with two chronometers; take one or three." * Our three time ...
TOOL
0.909277
6.509715
65cb94bd-fc36-4672-85cf-0ca13f424c1c
mattwu4/C-Hackerrank
For loop/Solution.cpp
#include <iostream> #include <cstdio> using namespace std; int a; int b; int main() { // Complete the code. std::cin >> a; std::cin >> b; std::string small[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = a; i <= b; i++){ if(i > 9){ ...
ALGO
0.999947
4.214974
fca19c38-2ff2-4979-a41b-1f856781a9f5
hanriiver/algorithm
daily solved/9019.cpp
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <math.h> #include <stack> #include <limits.h> #include <queue> #include <memory.h> #include <map> using namespace std; int a, b; bool check[10001]; void bfs() { queue<pair<int, string>> qu; check[a] = true; ...
ALGO
0.999945
4.845289
5e159d39-8cd5-49a3-91b2-0b140180ea43
syahn/Problem-solving
HackerRank/CtCI/[5] Queues_A_Tale_of_Two_Stacks.cpp
// # Reflection // - It's second time to solve this problem. But I couldn't solve it at a time. // Because I didn't take account into time limit, so it couldn't pass it. // - Now, I'm confident to handle this kinds of tests. // - Linking two stacks can be used to make queue. // # Problem // A queue is an abstract ...
ALGO
0.998917
5.574718
0cec97b1-1a4d-4e17-a251-293a614baae3
wocantudou/ncnn-20240410
src/layer/x86/elu_x86.cpp
#include "elu_x86.h" #include "x86_activation.h" namespace ncnn { ELU_x86::ELU_x86() { #if __SSE2__ support_packing = true; #endif // __SSE2__ } int ELU_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const { int w = bottom_top_blob.w; int h = bottom_top_blob.h; int d = bottom_top_blob...
ALGO
0.994928
6.452909
c8ba2bfb-9b41-40f8-b7aa-8e01a238abcd
hadrienmichel/BEL1D
SurfaceWave/MuLTI/MuLTI-master/gpdc mex file WINDOWS/gpdc.cpp
/* matlab mex interface to geopsy dispersion calculation * usage: out = gpdc(T, Vp, Vs, d) out = gpdc(T, Vp, Vs, d, 'nSamples', n, 'minRange', mn, 'maxRange', mx) out = gpdc(T, Vp, Vs, d, 'fV', f) where required input: T = Thickness(m) : double vector Vp = Vp (m/s) : double vec...
ALGO
0.997645
5.456806
f58ee062-89df-4f40-ae82-8ef137481181
joaopaulozz/C
Funções/PotenciaManuals.cpp
#include <stdio.h> int main() { int i,pot,base,exp; scanf("%i %i",&base,&exp); for(i=0;i<exp;i++) { base = base * exp; } printf("%i",base); return 0; }
ALGO
0.999995
3.970117
4e6be846-cfee-47ff-a48a-f313be0ef5ef
gurjotsc/gcheema-cp
leetcode/medium/minimumLinesToRepresentALineChart.cpp
class Solution { public: int minimumLines(vector<vector<int>>& stockPrices) { int n = stockPrices.size(); sort(stockPrices.begin(), stockPrices.end()); if(n <= 2) return n - 1; int res = 1; for(int i = 2; i < n; ++i) { auto prev = stockPrices[i-1]; aut...
ALGO
0.999488
5.756704
9d50bbdd-cf22-427a-9f50-fc81bfc85ca6
voldenuit-yanagi/MIT-6.837-Fall2004
Assignment1/Assignment1/sphere.cpp
#include "sphere.hpp" bool Sphere::intersect(const Ray &r, Hit &h, float tmin) { Vec3f r0 = center - r.getOrigin(); float tp = r0.Dot3(r.getDirection()); float d2 = r0.Dot3(r0) - tp*tp; if (d2 > (radius*radius)) { return false; } float tpp = sqrt(radius*radius - d2); float length = ...
ALGO
0.955131
5.046341